Can't Hide Then Show Control In Angular 4 Reactive Form Using Select

后端 未结 1 1937
感情败类
感情败类 2021-02-10 21:54

I am unable to toggle between hiding and showing a control using a select embedded in an Angular 4 reactive form. The following shows the issue: https://plnkr.co/edit/s7wYqy3Oa9

1条回答
  •  渐次进展
    2021-02-10 22:36

    Update hidden to the following checking the true string

    [hidden]="myForm.controls.isNameOnly.value == 'true'"
    

    https://plnkr.co/edit/7ub2fy7CBdBA46i4qkvv?p=preview

    I believe myForm.controls.isNameOnly.value returns a string and [hidden] evaluates it as an expression and since "true" or "false" are both non empty strings, so hidden is always true

    0 讨论(0)
提交回复
热议问题