Ng2.x 常見錯(cuò)誤總結(jié)。
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規(guī)定,當(dāng)在表單中使用 [(ngModel)] 時(shí),必須要定義 name 屬性。沒有name屬性就會(huì)報(bào)上面的錯(cuò)誤
解決辦法:給表單標(biāo)記添加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' //外部模板
})