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'}] ;
您可以直接使用.push
因为options
是一个数组
this.countriesSignup[0].options.push({text: 'Contractor', value: '2'});
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({})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.