AngularJs ReferenceError:角度未定义 [英] AngularJs ReferenceError: angular is not defined
问题描述
我尝试添加自定义过滤器,但如果我使用以下代码:
I trying to add a custom filter, but if I use the following code:
angular.module('myApp',[]).filter('startFrom', function() {
return function(input, start) {
start = +start; //parse to int
return input.slice(start);
}
});
但如果我这样做,我会在萤火虫中得到:ReferenceError: angular is not defined".
But if I do so, I get: "ReferenceError: angular is not defined" in firebug.
应用程序的其余部分工作正常,我在标签 div 中而不是在标签 html 中使用 ng-app,并且 https://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js
The rest of application is working fine, I am using ng-app in a tag div not in tag html, and https://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js
推荐答案
好吧,这是一个单页应用程序,使用的解决方案是:
Well in the way this is a single page application, the solution used was:
像任何其他控制器一样使用 AJAX 加载内容,然后调用:
load the content with AJAX, like any other controller, and then call:
angular.bootstrap($('#your_div_loaded_in_ajax'),["myApp","other_module"]);
这篇关于AngularJs ReferenceError:角度未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!