NG2常见错误总结

Ng2.x 常见错误总结。

1.EXCEPTION:... caused by: If ngModel is used within a form tag, either the name attribute must be set or the form control must be defined as 'standalone' in ngModelOptions.

原因:Angular2规定,当在表单中使用 [(ngModel)] 时,必须要定义 name 属性。没有name属性就会报上面的错误

解决办法:给表单标记添加name属性即可

2.加载的模板不显示 Error: Uncaught (in promise): Failed to load xxx.html

moduleId - ES/CommonJS module id of the file in which this component is defined

@Component({
  moduleId: module.id,    //加上这句就可以了
  selector: 'xxx-xxx',
  templateUrl: 'xxx.component.html'  //外部模板
})

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容