Html 为什么类型错误:无法读取属性';无效';未定义的角度(角度4)
我正在创建我的第一个角度项目。我想验证我的表单。 html: 为什么我要在浏览器控制台中排队Html 为什么类型错误:无法读取属性';无效';未定义的角度(角度4),html,angular,Html,Angular,我正在创建我的第一个角度项目。我想验证我的表单。 html: 为什么我要在浏览器控制台中排队此错误: ERROR TypeError: Cannot read property 'invalid' of undefined at Object.eval [as updateDirectives] (RoomInformationCardComponent.html:92) at Object.debugUpdateDirectives [as updateDirectives] (core.es
此错误:
ERROR TypeError: Cannot read property 'invalid' of undefined
at Object.eval [as updateDirectives] (RoomInformationCardComponent.html:92)
at Object.debugUpdateDirectives [as updateDirectives] (core.es5.js:13067)
at checkAndUpdateView (core.es5.js:12251)
at callViewAction (core.es5.js:12599)
at execComponentViewsAction (core.es5.js:12531)
at checkAndUpdateView (core.es5.js:12257)
at callViewAction (core.es5.js:12599)
at execComponentViewsAction (core.es5.js:12531)
at checkAndUpdateView (core.es5.js:12257)
at callViewAction (core.es5.js:12599)
请解释我为什么会遇到这个错误?是否与尚未创建的表单相关
如何解决此问题?首先生成模板,然后将模板引用绑定到组件变量。首先需要确保模板引用已绑定,然后才能使用它
您可以将运算符(?)与它们一起使用
countOfChildBedInput?。无效
在声明时将其赋值为false。
export class RoomInformationCardComponent implements OnInit {
existChildBedInRoom: boolean;
@ViewChild('childBedInRoom') childBedInRoom: ElementRef;
constructor() { }
ngOnInit() {
this.existChildBedInRoom = false;
}
}
ERROR TypeError: Cannot read property 'invalid' of undefined
at Object.eval [as updateDirectives] (RoomInformationCardComponent.html:92)
at Object.debugUpdateDirectives [as updateDirectives] (core.es5.js:13067)
at checkAndUpdateView (core.es5.js:12251)
at callViewAction (core.es5.js:12599)
at execComponentViewsAction (core.es5.js:12531)
at checkAndUpdateView (core.es5.js:12257)
at callViewAction (core.es5.js:12599)
at execComponentViewsAction (core.es5.js:12531)
at checkAndUpdateView (core.es5.js:12257)
at callViewAction (core.es5.js:12599)