2014-04-30 80 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>