Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 我的第一个ui路由器应用程序-为什么不加载嵌套视图?_Angularjs_Angular Ui Router - Fatal编程技术网

Angularjs 我的第一个ui路由器应用程序-为什么不加载嵌套视图?

Angularjs 我的第一个ui路由器应用程序-为什么不加载嵌套视图?,angularjs,angular-ui-router,Angularjs,Angular Ui Router,我的应用程序在这里 我知道ui路由器正在正确加载,因为命名视图功能正常(单击“关于”)。但是,嵌套视图列表和段落不起作用,我已经检查了十几次代码中的差异。Chrome控制台中也没有错误 这是我正在尝试做嵌套的视图 <div class="jumbotron text-center"> <h1>The Homey Page</h1> <p>This page demonstrates nested views.</p>

我的应用程序在这里

我知道ui路由器正在正确加载,因为命名视图功能正常(单击“关于”)。但是,嵌套视图
列表
段落
不起作用,我已经检查了十几次代码中的差异。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>

url确实会更改。。。但是为什么不加载模板呢?

您可能在主视图(
partial home.html
)中错过了

我们可以有一个plnkr吗,您的代码看起来不错。也许我通常使用ui sref='home.list'。这和plunker一样可行吗?运行按钮在顶部,我已经提供了URL来查看页面的实时预览…你知道,我想知道,“这很奇怪…为什么没有子视图的位置?”它就在这里。。。谢谢
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 } ];
});