在缩小我的AngularJS应用程序后,我收到此错误:
n未使用显式注释,无法在严格中调用 模式
我认为它来自这个装饰者:
(function () {
function logDecoratorConfig($provide) {
$provide.decorator('$log', logDecorator);
}
function logDecorator($delegate) {
$delegate.debug = function (msg) {
var time = new Date().toString();
console.log(time + " : " + msg);
};
return $delegate;
}
angular.module('services')
.config(['$provide', logDecoratorConfig]);
}());
也许是因为logDecorator
函数也必须注释?我该怎么办?
答案 0 :(得分:2)
您还需要将$delegate
服务的缩小安全注入提供到logDecorator
函数中。请尝试以下两个选项。
选项#1:
function logDecoratorConfig($provide) {
$provide.decorator('$log', ['$delegate', logDecorator]);
}
选项#2:
function logDecoratorConfig($provide) {
$provide.decorator('$log', logDecorator);
}
function logDecorator($delegate) {
$delegate.debug = function (msg) {
var time = new Date().toString();
console.log(time + " : " + msg);
};
return $delegate;
}
logDecorator.$inject = ['$delegate'];