AngularJS未在PhoneGap的页面中加载

时间:2017-02-19 05:04:10

标签: javascript angularjs cordova phonegap-desktop-app

我能够让Angular Controller在index.html页面上运行,但它没有加载到任何其他页面上。 我的索引页是:

<!DOCTYPE html>
<html ng-app="myPhonegapApp">
<head>
    <script src="js/angular.min.js"></script>
    <script src="js/my-angscript.js"></script>
</head>
<body>
    <div class="views">
        <div class="view view-main">
             <div class="pages navbar-through toolbar-through">
                <div data-page="index" class="page">
                    <div class="page-content">
                        <div class="content-block">
                            <a href="mypage1.html">My Page1</a> <br>
                            <a href="mypage2.html">My Page2</a> <br>

                            <div ng-controller="myAngController">
                                <p>The name is : {{name}}</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript" src="cordova.js"></script>
    <script type="text/javascript" src="lib/framework7/js/framework7.min.js"></script>
    <script type="text/javascript" src="js/my-app.js"></script>
</body>
</html>

我从索引页面链接了mypage1.html,mypage1.html的代码与index.html完全相同,只更改了此部分:<div data-page="mypage1" class="page">

现在my-angscript.js是:

var app = angular.module("myPhonegapApp", []);

app.controller("myAngController", function($scope){

    $scope.name = "Johnny Doe";
});

代码在索引页面上正常工作。但是当我去mypage1.html时,它不起作用。它只显示{{name}}。我做错了什么?

PhoneGap: v6.4.3
AngularJS: v1.6.1

0 个答案:

没有答案