我的 index.html 文件内容:
<body background="img\loginback.jpg" ng-controller="SignInCtrl" > <button ng-click='signIn()'>SignUp</button> </body>
我的 app.js 包含:
angular.module('StatusLogger', ['ionic']) .controller('SignInCtrl', function($scope, $location) { $scope.signIn = function() { $location.path('home.html'); }; })
但是 home.html 没有被调用。 请帮助我,我在哪里做错了。
提前致谢。
最佳答案
使用$apply()。使用以下代码重试:
HTML
<div ng-app ng-controller="SignInCtrl">
<button ng-click="signIn()">SignUp</button>
</div>
JS
function SignInCtrl($scope, $location) {
$scope.signIn = function() {
$scope.$apply( $location.path( 'http://google.com' ) );
};
}
希望能帮到你。
关于android - 用于在 AngularJS for Android 应用程序中切换到新 html 页面的 Controller 功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23245589/