Differences between value and ngValue in Angular 5

前端 未结 5 446
轮回少年
轮回少年 2020-11-29 06:54

Today I realized about an unexpected (for me) behaviour of the reactive forms in Angular 5. The server was receiving from the app an string with the value "null" i

5条回答
  •  感情败类
    2020-11-29 07:36

    const items = ["foo", "bar", "baz"]

    
    

    using [value] when one of the options is selected the value will be foo, bar, baz

    
    

    using [ngValue] when one of the options is selected the value will be 0: foo, 1: bar, 2: baz

提交回复
热议问题