I am trying to configure the AngularJS UL router to certain states (ie, "project"), and if they do not match, the default is "root". The root status should be checked using the remote API (Firebase) and, based on the result, load the corresponding view.
In the example below, none of these requirements are met:
1) " http://website.com/project " corresponds to the state of "root", and not to the (previously defined) "project".
2) "fbutil" is not defined in the function "templateUrl" and cannot be entered.
Please help me solve these problems.
angular.module('app') .config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) { $stateProvider .state('project', { url: '/project', views: { 'mainView': { controller: 'ProjectCtrl as project', templateUrl: '/views/project.html' } } }) .state('root', { url: '/:id', views: { 'mainView': { templateUrl: function($stateParams, fbutil) { var ref = fbutil.ref('user_data', id); ref.once('value', function(dataSnapshot) { return '/views/' + dataSnapshot.$val() +'.html'; }, function(error) { return '/views/root.html'; }); } } } }) } ]);
source share