角度NG-观点的PhoneGap不工作 [英] angular ng-view phonegap is not working

查看:228
本文介绍了角度NG-观点的PhoneGap不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图与angularjs和PhoneGap的在Android的基础应用。但它似乎并不奏效。下面是我的源$ C ​​$ C文件:

I am trying to make basic app with angularjs and phonegap in android. But it doesn't seem to be working. Below are my source code files:

index.html的

index.html

    <!DOCTYPE html>
<html ng-app="main-app">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>Insert title here</title>
</head>
<body>
<div class="body-content" ng-controller="MainCtrl">
    <div class="loader-ajax" ng-show="isViewLoading"></div>
    <div ng-view></div>
</div>
    <script src="js/angular.js"></script>
    <script type="text/javascript" src="js/main.js"></script>
    <script type="text/javascript" src="cordova-2.3.0.js"></script>
    <script type="text/javascript" src="js/index.js"></script>
    <script type="text/javascript">
            app.initialize();
    </script>
</body>
</html>

main.js

main.js

var mobileApp = angular.module("main-app", []);

mobileApp.config(function ($routeProvider,$compileProvider) {

    $routeProvider
        .when("/",
        {
            templateUrl: "partial/home.html",
            controller: "homeController"
        })
        .when("/home",
        {
            templateUrl: "partial/home.html",
            controller: "homeController"
        });
    $compileProvider.urlSanitizationWhitelist(/^\s*(https?|ftp|mailto|file|tel):/);
});
mobileApp.controller("MainCtrl",function($scope){
    alert('Coming here');
    $scope.isViewLoading=true;
});
mobileApp.controller("homeController",function($scope){
    alert('Home Coming here');

});

index.js

index.js

var app = {
    initialize: function() {
        this.bind();
    },
    bind: function() {
        document.addEventListener('deviceready', this.deviceready, false);
    },
    deviceready: function() {
        // note that this is an event handler so the scope is that of the event
        // so we need to call app.report(), and not this.report()
        app.report('deviceready');
        angular.bootstrap(document, ['main-app']);
    },
    report: function(id) { 
        console.log("report:" + id);
    }
};

当应用程序越来越负荷,路由器似乎并没有工作,作为其不进入的HomeController。

When the app is getting load, router doesn't seem to work as its not getting into Homecontroller.

从我有现成的其他地方一样,这code应该工作。任何帮助将大大AP preciated。

From what I have ready everywhere else, this code should work. Any help would be greatly appreciated.

推荐答案

我有同样的问题,我只是找到了一个解决方案。看看<一href="http://stackoverflow.com/questions/15105910/angular-ng-view-routing-not-working-in-phonegap">Angular NG画面/路由不工作在PhoneGap的

I had the same problem, which I just found a solution to. Take a look at Angular ng-view/routing not working in PhoneGap

这篇关于角度NG-观点的PhoneGap不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆