Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript angular.js不';t工作在PhoneGap中的ng视图标记_Javascript_Cordova_Angularjs - Fatal编程技术网

Javascript angular.js不';t工作在PhoneGap中的ng视图标记

Javascript angular.js不';t工作在PhoneGap中的ng视图标记,javascript,cordova,angularjs,Javascript,Cordova,Angularjs,我尝试将angular.js与PhoneGap结合使用。它在chrome浏览器上运行良好。但不起作用 在模拟器上运行angular模块时,不会调用它。你知道吗 我的代码是这样的 index.html 尝试从此服务器下载angularjs和zepto文件,然后将其放入应用程序中。尝试引导api方法在deviceReady上手动启动应用程序。比如: function onDeviceReady() { ... angular.bootstrap(document, ['ngView'

我尝试将angular.js与PhoneGap结合使用。它在chrome浏览器上运行良好。但不起作用
在模拟器上运行angular模块时,不会调用它。你知道吗

我的代码是这样的

index.html
尝试从此服务器下载angularjs和zepto文件,然后将其放入应用程序中。

尝试引导api方法在deviceReady上手动启动应用程序。比如:

function onDeviceReady() {
    ...
    angular.bootstrap(document, ['ngView']);
    ...
}

document.addEventListener("deviceready", onDeviceReady, true);

我花了大概5个小时试图解决一个类似的问题。事实证明,出于某种原因,phone gap/cca将应用程序id预先添加到URL的哈希部分。因此,路由不匹配,用户不断被
$routeProvider.others()
调用转发回

(我后来发现CCA没有发布!)

无论如何,如果你在使用移动chrome工具和Phonegap时遇到问题,可以尝试在你的路线中添加两个可选的匹配组作为解决办法。例如,以这个例子:

$routeProvider.when('/', { templateUrl: 'templates/home.html', controller: 'HomeCtrl' });
$routeProvider.when('/some-page', { templateUrl: 'templates/some-page.html', controller: 'SomePageCtrl' });
$routeProvider.when('/another-page', { templateUrl: 'templates/another-page.html', controller: 'AnotherPageCtrl' });
$routeProvider.otherwise({ redirectTo: '/' });
路由与添加到URL的额外比特不匹配,但您可以这样处理:

$routeProvider.when('/:a?/:b?/some-page', { templateUrl: 'templates/some-page.html', controller: 'SomePageCtrl' });
$routeProvider.when('/:a?/:b?/another-page', { templateUrl: 'templates/another-page.html', controller: 'AnotherPageCtrl' });
$routeProvider.when('/:a?/:b?/', { templateUrl: 'templates/home.html', controller: 'HomeCtrl' });
$routeProvider.otherwise({ redirectTo: '/' });

注意我添加的两个可选组。还请注意,基本路由位于最后—否则,如果正确生成URL,它将匹配所有/大多数路由

同样的问题,也增加了一行。但Ripple-Nexus浏览器仍然卡住了。什么也没有发生。还有什么我需要做的吗?
function onDeviceReady() {
    ...
    angular.bootstrap(document, ['ngView']);
    ...
}

document.addEventListener("deviceready", onDeviceReady, true);
$routeProvider.when('/', { templateUrl: 'templates/home.html', controller: 'HomeCtrl' });
$routeProvider.when('/some-page', { templateUrl: 'templates/some-page.html', controller: 'SomePageCtrl' });
$routeProvider.when('/another-page', { templateUrl: 'templates/another-page.html', controller: 'AnotherPageCtrl' });
$routeProvider.otherwise({ redirectTo: '/' });
$routeProvider.when('/:a?/:b?/some-page', { templateUrl: 'templates/some-page.html', controller: 'SomePageCtrl' });
$routeProvider.when('/:a?/:b?/another-page', { templateUrl: 'templates/another-page.html', controller: 'AnotherPageCtrl' });
$routeProvider.when('/:a?/:b?/', { templateUrl: 'templates/home.html', controller: 'HomeCtrl' });
$routeProvider.otherwise({ redirectTo: '/' });