Javascript 角载荷有时才发生
嗨,所以我在尝试使用Angular时遇到了一个奇怪的错误 当我使用angular访问页面时,有时会出现以下js错误:Javascript 角载荷有时才发生,javascript,jquery,angularjs,handlebars.js,Javascript,Jquery,Angularjs,Handlebars.js,嗨,所以我在尝试使用Angular时遇到了一个奇怪的错误 当我使用angular访问页面时,有时会出现以下js错误: Uncaught Error: [$injector:modulerr] Failed to instantiate module trainingApp due to: Error: [$injector:nomod] Module 'trainingApp' is not available! You either misspelled the module name or
Uncaught Error: [$injector:modulerr] Failed to instantiate module trainingApp due to:
Error: [$injector:nomod] Module 'trainingApp' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
我可以刷新页面,然后加载模块,每次刷新时页面都会按预期显示,并正确加载。当我点击从非角度页面到角度页面的链接时,似乎加载失败
下面是一些代码:
在标记中启动我的应用程序:
<div ng-app="trainingApp" ng-controller="listController">
我有一种感觉,这可能与interpolateProvider有关,以更改模板标记,视图首先通过Mustach渲染,因此我们更改了模板标记,使其在Mustach渲染模板后不会消失
任何想法或帮助都将不胜感激
谢谢介意我问一下-你为什么要留胡子?不确定它是否与您的问题相关,尽管Angular有自己的模板引擎。是的,我认为这是潜在的问题。。。我们还没有完全采用angular,所以我们进行了更多的实验。使用php在服务器端呈现小胡子。我可能需要重做一些,采用angular 100%,或者回去使用jquery,因为这个网站没有使用angulars的很多单页应用程序。你在页面中定义angular代码的地方?也许你只需要在调用
ng app
之前将其升级。几周前,我在与Apache Cordova合作时经常遇到这个问题。从来没有真正尝试去发现原因。
var app = angular.module('trainingApp', []);
app.config(['$interpolateProvider',function($interpolateProvider) {
$interpolateProvider.startSymbol('[[');
$interpolateProvider.endSymbol(']]');
}]);
app.controller('listController',['$scope','$http', '$log', function($scope, $http, $log) {
$http.get('/ajax/seminar-list.php?q='+$("#seminarID").val()+'&t='+new Date().getTime())
.success(function(data){
if (data.length > 0)
{
$scope.lists = data;
$(".listController").show();
}
});
}]);