ngFor计数没有任何数组或对象,以及如何在ngFor中再次使用ngFor?

时间:2017-11-09 20:39:38

标签: angular ionic-framework ionic2 ionic3 ionic-native

  

我想显示从0到用户的计数 - >术语。   如何将此计数数字添加到下拉列表中

     

https://stackblitz.com/edit/ionic-djze7u   请查看此编辑链接

     

Home.html中

<ion-content padding>
  <ion-card>
    <ion-card-content *ngFor="let item of users">

     //Here Already I have added a *ngfor so how can i solve this ?

      <ion-row>
        <ion-label>{{item.name}}:</ion-label>
        <ion-label>{{item.age}}</ion-label>
        <ion-select [(ngModel)]="count">
          <ion-option value="0" selected>0</ion-option>
  

//此处下拉列表将显示从0到item.term

          <ion-option ngfor="let i=1 | i<item.term;" value="{{i}}" >{{i}}</ion-option>
        </ion-select>
      </ion-row>
    </ion-card-content>
  </ion-card>
</ion-content>
  

Home.ts

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {
  users:any = [
    { name: 'Composite Factory', age: 1, term:2 },
    { name: 'Todd', age: 2, term:1 },
    { name: 'Lisa', age: 3, term:4 }
  ];
  constructor(public navCtrl: NavController) {

  }

}

0 个答案:

没有答案