如何使用angular将html页面链接到ionic中的按钮?
我正在制作一个ionic 1应用程序,当我点击一个按钮时,我想打开一个页面。我曾尝试使用在线教程来打开一个页面,但似乎没有任何帮助。我知道如何用HTML来完成它,但我对angular是新手 Index.html如何使用angular将html页面链接到ionic中的按钮?,html,angularjs,ionic-framework,Html,Angularjs,Ionic Framework,我正在制作一个ionic 1应用程序,当我点击一个按钮时,我想打开一个页面。我曾尝试使用在线教程来打开一个页面,但似乎没有任何帮助。我知道如何用HTML来完成它,但我对angular是新手 Index.html <body ng-app="starter"> <ion-pane> <ion-header-bar class="bar-stable"> <h1 class="title">Ionic Blank
<body ng-app="starter">
<ion-pane>
<ion-header-bar class="bar-stable">
<h1 class="title">Ionic Blank Starter</h1>
</ion-header-bar>
<div class="bar bar-header">
<h1 class="title">Header</h1>
</div>
<div class="bar bar-subheader">
<h2 class="title">Sub Header</h2>
<div class="button-bar bar-balanced">
<a class="button">First page </a>
<a class="button">Second page </a>
<a class="button">Third page</a>
</div>
</div>
<ion-content>
</ion-content>
</ion-pane>
</body>
Ionic默认使用angular的ui路由,因此您可以执行以下操作:
angular.module('starter', ['ionic'])
.config(function ($stateProvider, $urlRouterProvider) {
$stateProvider
.state("first", {
url: "/first",
template: "<div>This is first page</div>"
});
// other states
// default
$urlRouterProvider.otherwise("/first");
});
angular.module('starter',['ionic']))
.config(函数($stateProvider,$urlRouterProvider){
$stateProvider
.州(“第一”{
url:“/first”,
模板:“这是第一页”
});
//其他国家
//违约
$urlRouterProvider。否则(“/first”);
});
然后在按钮中:
<a class="button"
ui-sref="first">First page </a>
第一页
以及让爱奥尼亚知道在哪里加载视图的地方:
<ion-nav-view></ion-nav-view>
使用ui sref,它会更改html页面的状态,因为angular是一个单页应用程序,不需要单击,无论您如何命名,页面的状态都是您在ui sref中调用的状态。比如说 .state('thispage'{ url:“thispage” templateUrl:“/thispage.html” //控制器:“thispageCtrl” }
所有这些都在状态提供程序中。我在你的应用程序中看不到任何路由机制,也没有绑定到按钮的操作。首先做一些教程我已经做了关于角度的教程,它们都显示了使用ngrouting的方法,当我在ionic中实现时,该方法不起任何作用。这就是为什么我提供了一个空白代码,以便有人可以告诉我如何使用ngrouting这样做。Devqon的是当我单击按钮时我不需要onclick()吗?不,这就是
ui sref
的用途。您也可以在ng单击中执行此操作,但您应该仅在应用更多逻辑而不仅仅是路由的情况下执行此操作
<ion-nav-view></ion-nav-view>