我的应用就在这里 http://ui-router2-dwilbank68.c9.io/
我知道ui-router正确加载,因为NAMED视图功能正常(单击关于)。但是,嵌套视图list
和paragraph
无法正常工作,我已经查看了十几次代码中的差异。 Chrome控制台中也没有错误。
这是我试图在...中嵌套的视图。
<div class="jumbotron text-center">
<h1>The Homey Page</h1>
<p>This page demonstrates nested views.</p>
<a ui-sref='.list' class='btn btn-primary'>List</a>
<a ui-sref='.paragraph' class='btn btn-primary'>Paragraph</a>
</div>
这是我的整个javascript内容
var routerApp = angular
.module('routerApp', ['ui.router']);
routerApp.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/home');
$stateProvider
// HOME STATES AND NESTED VIEWS ========================================
.state('home', {
url: '/home',
templateUrl: 'partial-home.html'
})
.state('home.list', {
url: '/list',
templateUrl: 'partial-home-list.html',
controller: function($scope){
$scope.dogs = ['Bernese','Husky','Goldendoodle'];
}
})
.state('home.paragraph', {
url: '/paragraph',
template: 'I could use a taco right now'
})
// ABOUT PAGE AND MULTIPLE NAMED VIEWS =================================
.state('about', {
url: '/about',
views: {
'': {templateUrl: 'partial-about.html'},
'columnOne@about': { template: 'Look I am a column' },
'columnTwo@about': {
templateUrl: 'table-data.html',
controller: 'scotchController'
}
}
});
});
routerApp
.controller('scotchController', function($scope){
$scope.message = 'test';
$scope.scotches = [
{ name: 'Macallan 12', price: 50 },
{ name: 'Chivas Regal Royal Salute', price: 10000 },
{ name: 'Glenfiddich 1937', price: 20000 } ];
});
网址会改变......但为什么模板不加载?
答案 0 :(得分:2)
您的主视图(<div ui-view></div>
)
partial-home.html