hasError(typeofvalidator:string, controlname:string) : boolean
{
return this.CustomerModel.formCustomerGroup.contains[controlname].hasError(typeofvalidator);
}
我正在学习Angular ,在课程视频有相同的代码,但它在课程中运行,但我得到错误.我不知道我做错了什么需要帮助,请.
hasError(typeofvalidator:string, controlname:string) : boolean
{
return this.CustomerModel.formCustomerGroup.contains[controlname].hasError(typeofvalidator);
}
我正在学习Angular ,在课程视频有相同的代码,但它在课程中运行,但我得到错误.我不知道我做错了什么需要帮助,请.
4条答案
按热度按时间zpjtge221#
也许可以尝试将
contains
后面的方括号[]
替换为普通括号()
?看起来错误提示您正在尝试对函数进行索引。所以看起来应该更像这样:
在此之后,我假设您最初的错误将得到解决,但可能会有另一个错误。
hrysbysz2#
要调试此问题,请将每个步骤分解为几个强类型变量。
我不知道为什么你的方法不起作用,我肯定我的方法也不会起作用,不管你的方法是什么原因不起作用,但它会把问题分解成一个非常容易识别的点,然后你就可以从那里开始工作。
当你修复了它,你可以改变它回到较短的版本,如果你喜欢,但在这里你遇到了一个障碍,它的时间去搜索。
祝你好运!
kyks70gy3#
它不包含您应该使用控件而不是尝试此操作
返回这个.NewCustomer .FormCustomerGroup .控件[控件名称] .hasError(验证器类型);
4sup72z84#
问题就在这里:
解决方法:
只需将
controlname
替换为ControlName
即可。