2016-12-14 141 views
1

我已經開始學習離子。我打算設置默認路由到我的home.html但它不起作用。在Ionic AngularJS中設置默認視圖

的index.html

<ion-header-bar align-title="left" class="bar-positive"> 
     <div class="buttons"> 
     <button class="button icon ion-navicon"></button> 
     </div> 
     <h1 class="title" style="text-align: center;">Title!</h1> 
     <div class="buttons"> 
     <button class="button icon ion-home"></button> 
     </div> 
    </ion-header-bar> 
    <ion-nav-view></ion-nav-view> 

home.html的

<h1>Hello world!</h1> 

app.js

.config(function ($stateProvider, $urlRouterProvider) { 
    $stateProvider 

     .state('home', { 
     url: '/', 
     views: { 
      'login': { 
      templateUrl: 'templates/home.html', 
      controller: 'PlaylistsCtrl' 
      } 
     } 
     }) 
    // if none of the above states are matched, use this as the fallback 
    $urlRouterProvider.otherwise('/'); 
    }); 

幫助我在那裏做錯誤的。

+0

嘗試'$ urlRouterProvider.otherwise( '/家庭');' –

回答

1

我想你應該改變家的網址

.state('home', { 
     url: '/home', 
     views: { 
      'login': { 
      templateUrl: 'templates/home.html', 
      controller: 'PlaylistsCtrl' 
      } 
     } 
     }) 
    // if none of the above states are matched, use this as the fallback 
    $urlRouterProvider.otherwise('/home');