I use ui-router for nested states and views. When I click on the link, the URL changes to the URL for the substation, but the template does not load.
For example, when the URL changes to the project/settings subelement, the corresponding project.settings.html template is not loaded.
Here is the courtesy of SSCCE Plunkr
Below is my code:
app.js
myApp.config(function ($stateProvider, $urlRouterProvider){ $stateProvider .state('project', { url: "/project", views:{ "content":{templateUrl: "partials/project.html"}, "header":{templateUrl: "partials/header"} } }) .state('project.settings', { url: "/settings", views:{ "content":{templateUrl: "partials/project.settings.html"}, "header":{templateUrl: "partials/header"} } }) $urlRouterProvider.otherwise("/") }); myApp.run(function($rootScope,$location,$cookieStore,validateCookie,$state) { $rootScope.$on('$stateChangeStart',function(event,toState,toParams,fromState){ if($cookieStore.get('user')){ validateCookie.authService(function(result,error){ if(!result){ $location.path("/"); }else{ $state.go('project.settings'); } }); } else{ $location.path("/"); } }); });
index.html
<div ng-controller="userController"> <div ui-view="header"></div> <div class="container" ui-view="content"></div> </div>
project.html
<div ng-controller="userController"> <div class="details"> <a ui-sref=".settings" class="btn btn-primary">Settings</a> </div> </div>
project.settings.html
<h1>Project Setting -State test</h1>
javascript angularjs angular-ui-router
Sajin M Aboobakkar Jan 29 '14 at 7:17 2014-01-29 07:17
source share