angular-assertArg

angular 1.5.8 源码解析

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/**
* throw error if the argument is falsy.
*/

function assertArg(arg, name, reason) {
//如果arg 判断错误 就抛出ngMinErr
if (!arg) {
throw ngMinErr('areq', "Argument '{0}' is {1}", (name || '?'), (reason || "required"));
}
return arg;
}

//接受数组的annotate
//比如['$scope',function($scope){}]
function assertArgFn(arg, name, acceptArrayAnnotation) {
if (acceptArrayAnnotation && isArray(arg)) {
arg = arg[arg.length - 1];
}

assertArg(isFunction(arg), name, 'not a function, got ' +
(arg && typeof arg === 'object' ? arg.constructor.name || 'Object' : typeof arg));
return arg;
}
欢迎关注我的公众号:沉迷Spring
显示 Gitment 评论
0%