2017-03-24 89 views
1

我只是想导航到另一个页面。但href不起作用。离子href不工作

HTML代码:

<a class="item item-avatar" href="#/app/top"> 
    <img src="../img/cool.png"> 
    <h2>Cool Status <p style="float:right;"> >></p></h2> 
</a> 

在App.js

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

.state('app.top', { 
    url: '/top', 
    views: { 
    'menuContent': { 
     templateUrl: 'templates/top.html' 
    } 
    } 
}); 
}); 

我也 https://forum.ionicframework.com/t/ionic-href-not-working/17750 但还在读书论坛HREF不工作

+0

要么你缺少路由在你的例子这里或在href应该是'#/ top' – George

+0

你应该使用'UI -sref = “app.top”' – devqon

回答

2

我假设任何导航形式将起作用。

HTML代码:

<a class="item item-avatar" href="#/top"> 
    <img src="../img/cool.png"> 
    <h2>Cool Status <p style="float:right;"> >></p></h2> 
</a> 

App.js

.config(function($stateProvider, $urlRouterProvider) { 
    $stateProvider 
     .state('top', { 
      url: '/top', 
      templateUrl: 'templates/top.html' 
     }); 

    $urlRouterProvider.otherwise("/"); 
});