2016-12-14 83 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');