蚂蚁 - 可以绑定到' ngmodel'由于它是Nz-Switch的已知属性,因此
我正在为Angular(NG-Zorro-Antd)使用ANT设计,并使用Simple Switch
模块显示开关。
当我根据文档添加代码时:
< nz-switch [ngmodel] =“ true”></nz-switch>
该应用程序不会编译,我会收到此错误:
无法绑定到“ ngmodel”,因为它不是'nz-switch'的已知属性
I'm using Ant Design for Angular (ng-zorro-antd), and using the simple switch
module to display a switch.
When I add the code per the docs:
<nz-switch [ngModel]="true"></nz-switch>
The app won't compile, and I get this error:
Can't bind to 'ngModel' since it isn't a known property of 'nz-switch'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
import
formsModule
在右模块中 ,虽然它在文档,您需要让Angular的
form> formsmodule
以ngmodel
绑定到工作。如果您只有一个带有一个模块的应用程序,这很容易。只需在您的一个和唯一的
xxx.module.ts
文件中以下面的形式导入formsmodule
。使用
nz-switch
的模块中如果您正在使用具有多个模块的应用程序,则必须确保将其导入在中 >模块,在使用
nz-switch
的位置,在xxx.module.ts
文件中:您应该很好。
Import
FormsModule
in the right moduleWhile it doesn't say it in the documentation, you need to have Angular's
FormsModule
imported in order for thengModel
binding to work.If you have an app with just one module, this is easy. Simply import the
FormsModule
as below in your one and onlyxxx.module.ts
file.If you're working on an app with multiple modules, you have to ensure you're importing it in the module where you're going to use the
nz-switch
In that module, where you're using the
nz-switch
, in thexxx.module.ts
file:You should be good to go.