【问题标题】:Ng-route works in pc but not in emulator (cordova)Ng-route 在 pc 中有效,但在模拟器中无效(cordova)
【发布时间】:2015-12-10 09:43:24
【问题描述】:

当我从主机(使用 chrome)运行我的项目时,它可以使用所有导航而没有任何错误。

但是当我在 GenyMotion 模拟器上运行它时,它就不行了。除非我将模板作为字符串而不是 URL:

var myApp= angular.module('MyApp', [
    'ngRoute',
    'ngAnimate',
    'ngMaterial'
]);
myApp.config(function ($routeProvider) {

$routeProvider
            .when('/test', { /////////////////////////THIS IS WORKING
                template : '<span> AHEY </span>',
                controller  : 'testController'
            })
            .when('/LoginPage', {/////////////////////////THIS IS NOT WORKING
                templateUrl : 'LoginPage.html',
                controller  : 'loginController'
            })
});

我的html:

<!DOCTYPE html>

<html ng-app="MyApp">

    <head>
        ...     
    </head>
    <title>My App</title>
    <body ng-controller="mainController">
        <div id="header" layout="row" > </div>
        <div ng-view></div>
        <script> .... </script>
    </body>
</html>         

【问题讨论】:

  • 你能在命令提示符下检查 adb logcat -c 吗?
  • 如果我写adb logcat -c,我什么都不带。但我有一个正在运行的 logcat,上面写着:no content-security-policy meta tag found. please add one when using the whitelist plugin。不知道是不是和这个问题有关?
  • 尝试android平台19并进行构建和检查

标签: javascript android angularjs cordova ngroute


【解决方案1】:

原因:区分大小写

虽然 url 被 js 不敏感地解释,但在 android 或 ios 中并非如此。

因此,如果一切正常,请检查路径中的案例。

【讨论】:

    猜你喜欢
    • 2017-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-23
    • 1970-01-01
    • 1970-01-01
    • 2015-08-25
    相关资源
    最近更新 更多