Can't bind to 'ngValue' since it isn't a known property of 'option'

前端 未结 3 714
谎友^
谎友^ 2021-02-18 16:40

I am trying to implement select in Angular 5 but I am constantly getting this

I\'ve tried many StackOverflow questions already, The only difference

3条回答
  •  北恋
    北恋 (楼主)
    2021-02-18 16:51

    I was doing a very silly mistake and got into this issue.

    1. Instead of using [ngValue]="ctn.value"
    2. I was supposed to use [value] I was importing formsModule inside parent module, I should have imported it in child module to make [(ngModel)] work
    3. [value] should be [(value)] if we want the default selection show up.

    so my final component code is.

    
      
    

提交回复
热议问题