Difference between ngValue and value in angular - We are open to use Angular value or ngValue and the only difference between two is that the “value” is always “string”, where in “ngValue” you can pass “object”. Let’s see the below examples in details, Example 1, const items = [ "Anil" , "Sunil" , "Sushil" ] Use of value - < option * ngFor = "let item of items" [ value ]= "item" > {{ item }} </ option > Result - using [value] when one of the options is selected the value will be Anil, Sunil, Sushil. Use of ngValue - < option * ngFor = "let item of items" [ ngValue ]= "item" > {{ item }} </ option > Result - using [ngValue] when one of the options is selected the value will be 0: Anil, 1: Sunil, 2: Sushil Example 2 , import { Component } from '@angular/core' ; @ Component ({ selector: 'example-app' , ...
Angular, React, JavaScript, Java, PHP, SQL, C#, Vue, NodeJs, TypeScript and Interview Questions Answers