Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 如何选择离子2选择中的第一个选项。所选属性不工作_Angular_Ionic Framework_Ionic2 - Fatal编程技术网

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) {
            //...