angular-assertArg 发表于 2017-03-14 | 更新于 2019-05-07 | 评论数: | 阅读次数: angular 1.5.8 源码解析12345678910111213141516171819202122/*** 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 本文作者: John | 微信公众号【沉迷Spring】 本文链接: http://johnwonder.github.io/2017/03/14/angular-assertArg/ 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!