按钮点击不在离子框架中打开新页面
问题描述:
这是我的代码。我想在用户点击“登录”按钮时打开一个新页面。我已经写了配置功能并且也设置了状态名。为什么我的"applicaion.html"
页面未打开。按钮点击不在离子框架中打开新页面
在控制台中,我可以看到用户名称打印,但$state.go('apps')
行不起作用。
[http://codepen.io/skpatel/pen/XbVjKJ][1]
[1]: http://codepen.io/skpatel/pen/XbVjKJ
答
看到这个更新的代码:http://codepen.io/anon/pen/PqEpbR?editors=101
你错过以下内容的index.html:添加引用ui-view
(从UI路由器)正在管理的看法的变化。 你的代码在index.html中是静态的,没有引用新页面。
Ui视图已添加到index.html。这是ui-router指令,并且是强制性的。离子使用UI路由器
<body>
<div ui-view></div>
</body>
我已经放出来的登录页面的代码放到一个脚本模板:
<script type="text/ng-template" id="home.html">
<ion-header-bar class="bar-calm">
<h1 class="title">Application Permissions</h1>
</ion-header-bar>
<ion-content padding="true" has-header="true" padding="true" ng-controller="HomeCtrl">
<p>Welcome to the privacy mirror home page!</p>
<p>Enter your name and then you can just tap the login button to be logged in</p>
<label class="item item-input" class="padding">
<input type="text" placeholder="Username" ng-model="user.username" required>
</label>
<div class="padding">
<button class="button button-block button-stable" ng-click="login()">Login</button>
</div>
</ion-content>
</script>
又创造了apps.html t
emplate:
<script type="text/ng-template" id="apps.html">
THIS IS MY APP PAGE
</script>
最后,有要更新的路由规则指向home.html
.state('home', {
url: '/home',
templateUrl: 'home.html',
controller: 'HomeCtrl'
})
谢谢让我试试我自己 –
根据本教程,它不是强制要放'ui-view'。为什么?我对这项技术是全新的,对于愚蠢的问题感到抱歉 –
我编辑了我的回复,其中包括ui-view部分 – aorfevre