android - 用于在 AngularJS for Android 应用程序中切换到新 html 页面的 Controller 功能

标签 android angularjs

我的 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/

相关文章:

Android 如何在发布前获取 Google Play 商店链接

java - Java 和 Android 中 StringBuffer 类的不同行为

java - 如何在 Android Studio 中将 ImageView 转换为字节数组?

AngularJS - 使用参数调用 ng-submit

css - HTML/CSS 页面中的布局挑战

html - 在弹出窗口打开时向按钮添加 css 样式。关闭时将其删除

java - 亚行——它是如何运作的?

android - LVL 错误 - 无法在我的项目中引用 LVL

javascript - 使用 Angular-translate 进行参数格式化

javascript - Angular 在 ng-src 中对 url 进行编码,并将 '/' 替换为 %2F,将 '?' 替换为 %3F