Skip to main content
added 50 characters in body
Source Link
FAISAL
  • 176
  • 1
  • 5

You don't need to declare an extra reference variable. I would suggest the first approach i.e. using [(ngModel)] for two-way data binding.

However, in the first approach, you must initialize the model value before using it in your template i.e. fruit.description should not be undefined otherwise you'll get the following TypeError:

Cannot read property 'length' of undefined

Using the second approach, you wont get that error.

You don't need to declare an extra reference variable. I would suggest the first approach.

However, in the first approach, you must initialize the model value before using it in your template i.e. fruit.description should not be undefined otherwise you'll get the following TypeError:

Cannot read property 'length' of undefined

Using the second approach, you wont get that error.

You don't need to declare an extra reference variable. I would suggest the first approach i.e. using [(ngModel)] for two-way data binding.

However, in the first approach, you must initialize the model value before using it in your template i.e. fruit.description should not be undefined otherwise you'll get the following TypeError:

Cannot read property 'length' of undefined

Using the second approach, you wont get that error.

Post Migrated Here from stackoverflow.com (revisions)
Source Link
FAISAL
  • 176
  • 1
  • 5

You don't need to declare an extra reference variable. I would suggest the first approach.

However, in the first approach, you must initialize the model value before using it in your template i.e. fruit.description should not be undefined otherwise you'll get the following TypeError:

Cannot read property 'length' of undefined

Using the second approach, you wont get that error.