You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
相当于 new RegExp("\{\d+\}", "g")//g代表 global match(全定匹配)
其次是return new Error(message),这个
ngMinErr=minErr("ng");throwngMinErr("badname","hasOwnProperty is not a valid {0} name","module");
抛出打印的异常
functioncheckInput(x){try{if(isNaN(parseInt(x))){thrownewError("Input is not a number.");}}catch(e){document.write(e.description);console.log(newError("Input is not a number."));}}checkInput("not a number");
angular minErr函数的源码是这样的,这个函数主要用来输出错误的提示信息
从这个函数中可以学到几点东西
首先是里面这个正则
template.replace(/\{\d+\}/g)
这个正则是匹配所有"{1个或更多数字}"形式的字符串
例如
相当于
new RegExp("\{\d+\}", "g")//g代表 global match(全定匹配)
其次是return new Error(message),这个
抛出打印的异常
输出如下的异常信息
Uncaught Error: [ng:badname] hasOwnProperty is not a valid module name
http://errors.angularjs.org/1.2.1/ng/badname?p0=module"
这里如果throw new Error("wscats");之后,后面的代码就会得不到执行
The text was updated successfully, but these errors were encountered: