在刚学AngularJS的时候总会出现各种各样的错误,今天做一个小小的总结

第一条:

Uncaught SyntaxError: Unexpected identifier

AngularJS常见报错总结

原因:代码中少了一个英文逗号,加上逗号就正常了,如:

AngularJS常见报错总结


第二条:

Error: [ng:areq] http://errors.angularjs.org

这个错误的一般是没有找到controller. 写上一个正确的controller就正常了。

AngularJS常见报错总结


第三条:编写指令模板的属性的时候应当使用 app-指令名称,这样写的原因是防止以后html语言升级,指令名称和新增属性冲突。

AngularJS常见报错总结


第四条:在指令中使用replace:true,时,要替换的html模板只能有一个根元素,否则就会报此错误。

Error: [$compile:tplrt]

AngularJS常见报错总结

AngularJS常见报错总结


第五条:TypeError: Cannot set property 'list' of undefined

或者忘了写依赖Error: [$injector:itkn]

控制器前面忘了写$scope,补上$scope

AngularJS常见报错总结

AngularJS常见报错总结


相关文章:

  • 2021-12-09
  • 2021-11-05
  • 2022-02-03
  • 2021-12-02
  • 2021-10-04
  • 2021-12-13
  • 2021-07-27
  • 2022-12-23
猜你喜欢
  • 2021-07-14
  • 2022-12-23
  • 2022-02-18
  • 2022-12-23
  • 2021-10-09
  • 2021-07-11
相关资源
相似解决方案