Phonegap适用于桌面,但不适用于移动Android

时间:2015-01-05 10:47:12

标签: javascript android angularjs cordova

我正在使用Phonegap和AngularJS开发移动应用程序,到目前为止,该应用程序在桌面浏览器中运行良好。虽然,当我将其构建为APK时,应用程序的某些代码不起作用。 首先,我已经看到了这个主题Phonegap - app works on desktop, not on mobile,问题仍在继续。

的index.html

<!DOCTYPE html>
<html ng-app="home">
    <head>
        <meta charset="utf-8" />
        <title>My new Application</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
        <meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimal-ui" />
        <link rel="shortcut icon" href="/favicon.png" type="image/x-icon" />

        <link rel="stylesheet" href="public/css/angular/mobile-angular-ui-hover.min.css" />
        <link rel="stylesheet" href="public/css/angular/mobile-angular-ui-base.min.css" />
        <link rel="stylesheet" href="public/css/angular/mobile-angular-ui-desktop.min.css" />
        <link rel="stylesheet" href="public/css/global.css" />
    </head>

    <body>

      <div class="app">

            <div ng-include="'application/views/header.html'" style="margin-bottom: 51px"></div>

            <div ng-view="">

            </div>

            <div ng-include="'application/views/footer.html'"></div>

        </div>

        <script srC="cordova.js"></script>
        <script type="text/javascript" src="public/js/angular/angular.min.js"></script>
        <script type="text/javascript" src="public/js/angular/angular-route.min.js"></script>
        <script type="text/javascript" src="application/controllers/home.js"></script>
    </body>
</html>

home.js

var app = angular.module('home', [
    'ngRoute'
]);

app.config(function($routeProvider) {
    $routeProvider

        .when('/', {
            templateUrl : '/application/views/home/home.html',
            controller  : 'home_controller'
        })

});

app.controller('home_controller', ['$scope', '$location', function($scope, $location){

    console.log('im here..');
    alert('im here..!!');
}]);

我尝试通过设置console.logalert消息来“调试”,但都没有显示。 对于调试,我使用http://debug.build.phonegap.com/ weinre。

结论:我的应用程序正常显示,它会加载header.htmlfooter.html,但不加载home.html(也不会显示消息)。 我还尝试在body ng-controller="home_controller"中设置控制器,但route配置也应该这样做。

0 个答案:

没有答案