美文网首页
NG2常见错误总结

NG2常见错误总结

作者: 小学生的博客 | 来源:发表于2017-02-20 22:37 被阅读178次

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'  //外部模板
})

相关文章

网友评论

      本文标题:NG2常见错误总结

      本文链接:https://www.haomeiwen.com/subject/ftuewttx.html