2014-04-30 126 views
0

我正在尝试第一次使用Angular UI路由器。我有问题的意见不被相应地调用。检查闯入者:http://plnkr.co/edit/cBfR6u2BPJvKN16vi6hG?p=previewAngular UI路由器 - 不调用视图

路由器上有什么突出的东西吗?

deviceApp.config(function ($stateProvider) { 
    $stateProvider 
     .state('devices', { 
      views: { 
       'environment': { 
        template: 'Look I am a view!', 
        controller: 'DataCtrl' 
       }, 
       'devicedetail': { 
        templateUrl: 'index.html', 
        controller: 'DeviceCtrl' 
       }    

      } 
     } 
    )} 
    ); 

回答

0

也许在视图对象中没有“url”定义?

'environment': { 
        url: '/environment', 
        template: 'Look I am a view!', 
        controller: 'DataCtrl' 
       }, 
0

你可以做这样的事情:

config.js

.config(function ($urlRouterProvider) { 
    $urlRouterProvider.otherwise('/'); 
    $urlRouterProvider.when('', '/'); 
    }) 

app.js

state('main', { 
    url: '/', 
    views: { 
     '': { templateUrl: 'app/main/main.html', controller: 'MainCtrl'}, 
     'navbar': { templateUrl: 'components/navigation/navbar/navbar.html'}, 
    } 

的index.html

<body> 
    <header ui-view="navbar" class="header"></header> 
    <section class="content"> 
    <div ui-view></div> 
    </section> 
</body>