Reputation: 900
I have an Object:
public countriesSignup = [{
name: 'countries',
options: [
{text: 'Customer', value: '1'},
]
}];
My Final Object must be:
countriesSignup = [{
name: 'countries',
options: [
{text: 'Customer', value: '1'},
{text: 'Contractor', value: '2'},
]
}];
How i can add from Controller? I try this:
this.countriesSignup['options'] = [{text: 'Contractor', value: '2'}] ;
Upvotes: 1
Views: 2772
Reputation: 222582
You can directly use .push
since options
is an array
this.countriesSignup[0].options.push({text: 'Contractor', value: '2'});
Upvotes: 2
Reputation: 6949
Mistake#1
You are using Array of object, so you have to mention index also
So it should be
this.countriesSignup[0]
Mistake #2 Since options is array, you should use push
countriesSignup[0].options.push({})
Upvotes: 1