Though the states are changing successfully, I can't get the ui-view to update:
<a ui-sref="promo.foo">Foo state</a>
<a ui-sref="promo.bar">Bar state</a>
<div ui-view=""></div>
$urlRouterProvider.otherwise("/");
$stateProvider
.state('promo', {
url: "/",
abstract: true
})
.state('promo.foo', {
url: "promo/foo",
template: "'<h3>Foo</h3>'",
controller: function($scope) {
$scope.value = 'foo';
}
})
.state('promo.bar', {
url: "promo/bar",
template: "'<h3>Bar</h3>'",
controller: function($scope) {
$scope.value = 'bar';
}
})
I have also tried setting ui-view
to equal specific states also; and to dynamically change its RHS from my $scope
.
Since you're trying to create nested views, the home state should have a template with an ui-view-element in it. Also you have both double and single quotes in the template
template: "'<h3>Foo</h3>'"
Is this Plunker what you had in mind?
给您的抽象状态一个模板,其中包含您的子状态将在其中呈现的模板...例如http://scotch.io/tutorials/javascript/angular-routing-using-ui-router
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.