Angular 如何选择离子2选择中的第一个选项。所选属性不工作
我试图从Angular 如何选择离子2选择中的第一个选项。所选属性不工作,angular,ionic-framework,ionic2,Angular,Ionic Framework,Ionic2,我试图从中选择第一个值,但它不起作用。它在第一个变量中为真。如果我在循环中打印它。我想它通常是这样工作的 dashboard.html 我正在从构造函数调用上面的getLocations()函数。在仪表板中。ts尝试将ngModel变量location设置为第一个位置 this.catService.getLocations(id, this.user.apiToken, this.user.role_id).then(result => { this.locati
中选择第一个值,但它不起作用。它在第一个变量中为真。如果我在循环中打印它。我想它通常是这样工作的
dashboard.html
我正在从构造函数调用上面的getLocations()函数。在仪表板中。ts尝试将ngModel变量
location
设置为第一个位置
this.catService.getLocations(id, this.user.apiToken, this.user.role_id).then(result => {
this.locations = result;
this.location=this.locations[0].id;//here
let breakIt = false;
for (let key in this.locations) {
//...
getLocations(id) {
this.catService.getLocations(id, this.user.apiToken, this.user.role_id).then(result => {
this.locations = result;
if(this.user.role_id == 2) {
this.getDailyItemLogAdmin(this.firstLocationID, this.user.id);
}else if(this.user.role_id == 3) {
this.getDailyItemLogManager(this.firstLocationID, this.user.id);
}
})
}
this.catService.getLocations(id, this.user.apiToken, this.user.role_id).then(result => {
this.locations = result;
this.location=this.locations[0].id;//here
let breakIt = false;
for (let key in this.locations) {
//...