Javascript 离子骨架:Can';从我的控制器重定向到另一个页面?
尝试通过单击控制器使我的应用程序切换到其他页面时遇到问题。如果有人能给我指点一下我在这里遗漏了什么或做错了什么,我将不胜感激 这是我的app.js .config(函数($stateProvider,$urlRouterProvider){ 这是我的index.htmlJavascript 离子骨架:Can';从我的控制器重定向到另一个页面?,javascript,angularjs,ionic-framework,Javascript,Angularjs,Ionic Framework,尝试通过单击控制器使我的应用程序切换到其他页面时遇到问题。如果有人能给我指点一下我在这里遗漏了什么或做错了什么,我将不胜感激 这是我的app.js .config(函数($stateProvider,$urlRouterProvider){ 这是我的index.html <body ng-app="app" animation="slide-left-right-ios7"> <ion-view style="" title="MainMenu"> &
<body ng-app="app" animation="slide-left-right-ios7">
<ion-view style="" title="MainMenu">
<div class="bar bar-header bar-assertive">
<h1 class="title">Home</h1>
<a class="button icon-right button-clear ion-gear-a"></a>
</div>
<ion-content style="background-color: #e9efec" class="has-header" scroll="true" padding="true">
<div align="center" style="padding: 15%">
<img style="height: 60px; width: 180px" src="img/digicellogo.png">
</div>
<div style="" class="list card">
<div class="item item-body">
<form >
<label class="item item-input">
<a style="padding-right: 5px" href="">
<img style="height: 50px; width: 50px; " src="img/username-logo.JPG">
</a>
<input type="text" placeholder="DigicelID">
</label>
<label class="item item-input">
<a style="padding-right: 5px" href="">
<img style="height: 50px; width: 50px; " src="img/password-logo.JPG">
</a>
<input type="text" placeholder="Password">
</label>
<div align="right">
<button class="button button-clear button-assertive">
Forgot Password?
</button>
</div>
<a class="button button-block button-assertive" ng-click="testMove()" ng-controller="TestCtrl">
Login
</a>
<button class="button button-block button-assertive">
Sign Up
</button>
</form>
</div>
</div>
</ion-content>
</body>
尝试使用$state.go('userprofile');
而不是location.transitiono('/main菜单');
(请记住将
$state
注入您的控制器以测试此功能)是的,您尝试了此功能。它消除了“未定义的错误”,但按下时什么也不做?只是为了测试,如果您在运行爱奥尼亚服务时在浏览器中放入“localhost…/main菜单”,是否加载了正确的页面?
<body ng-app="app" animation="slide-left-right-ios7">
<ion-view style="" title="MainMenu">
<div class="bar bar-header bar-assertive">
<h1 class="title">Home</h1>
<a class="button icon-right button-clear ion-gear-a"></a>
</div>
<ion-content style="background-color: #e9efec" class="has-header" scroll="true" padding="true">
<div align="center" style="padding: 15%">
<img style="height: 60px; width: 180px" src="img/digicellogo.png">
</div>
<div style="" class="list card">
<div class="item item-body">
<form >
<label class="item item-input">
<a style="padding-right: 5px" href="">
<img style="height: 50px; width: 50px; " src="img/username-logo.JPG">
</a>
<input type="text" placeholder="DigicelID">
</label>
<label class="item item-input">
<a style="padding-right: 5px" href="">
<img style="height: 50px; width: 50px; " src="img/password-logo.JPG">
</a>
<input type="text" placeholder="Password">
</label>
<div align="right">
<button class="button button-clear button-assertive">
Forgot Password?
</button>
</div>
<a class="button button-block button-assertive" ng-click="testMove()" ng-controller="TestCtrl">
Login
</a>
<button class="button button-block button-assertive">
Sign Up
</button>
</form>
</div>
</div>
</ion-content>
</body>
.controller('TestCtrl',['$scope', '$state', function($scope, $state) {
$scope.testMove = function() {
console.log("Button was pressed!");
$state.go('userprofile');
};
}])