我刚刚建立了一个新的AngularJS项目。我已经通过angular
安装了angular-resource
和bower
,一切都很好。我已经安装了以前使用过的另一项服务-https://github.com/Fundoo-Solutions/angularjs-modal-service,但是当我注入模块时会导致以下错误:
未捕获的对象
它指向AngularJS中此函数的return语句:
function minErr(module) {
return function () {
var code = arguments[0],
prefix = '[' + (module ? module + ':' : '') + code + '] ',
template = arguments[1],
templateArgs = arguments,
stringify = function (obj) {
if (typeof obj === 'function') {
return obj.toString().replace(/ \{[\s\S]*$/, '');
} else if (typeof obj === 'undefined') {
return 'undefined';
} else if (typeof obj !== 'string') {
return JSON.stringify(obj);
}
return obj;
},
message, i;
message = prefix + template.replace(/\{\d+\}/g, function (match) {
var index = +match.slice(1, -1), arg;
if (index + 2 < templateArgs.length) {
arg = templateArgs[index + 2];
if (typeof arg === 'function') {
return arg.toString().replace(/ ?\{[\s\S]*$/, '');
} else if (typeof arg === 'undefined') {
return 'undefined';
} else if (typeof arg !== 'string') {
return toJson(arg);
}
return arg;
}
return match;
});
message = message + '\nhttp://errors.angularjs.org/1.2.18/' +
(module ? module + '/' : '') + code;
for (i = 2; i < arguments.length; i++) {
message = message + (i == 2 ? '?' : '&') + 'p' + (i-2) + '=' +
encodeURIComponent(stringify(arguments[i]));
}
return new Error(message);
};
}
我认为这是Error
不存在?
我是否缺少模块或其他东西?
[一个人因Angular遇到此错误的原因之一。您包含的模块未正确注入。例如,在使用前必须正确将其作为依赖项注入。因此,请确保已完成。
另外一个原因是正确定义ng-app="<app-name>"
,并确保您在其中编写了Angular应用程序代码的文件,例如:angular.module('<app-name>', [])
作为脚本文件包括在内。