2017-01-21 5 views
1

내 응용 프로그램 TS 파일에 개체 배열이 있습니다. 저장소에서 가져 오는 개체로 배열을 채 웁니다. 내 html 파일에ionic 2에서 객체 배열을 반복하는 방법은 무엇입니까?

import { Component, ViewChild } from '@angular/core'; 
import { Nav, Platform } from 'ionic-angular'; 
import { StatusBar, Splashscreen } from 'ionic-native'; 
import { Dbservice } from '../providers/dbservice'; 

import { Home } from '../pages/page1/page1'; 
import { Setup } from '../pages/frameSetup/setup'; 

export class Home { 
    deviceObj = []; 
    constructor(){ 
     this.deviceObj.push(otherObject); 
    } 
} 

나는 배열에보고 데이터를 표시 할, 그러나 나는이 작업을 수행 할 때 오류 메시지가 여기에

내 HTML 파일의 코드가 얻을.

polyfills.js:3 Error: Uncaught (in promise): Error: Template parse errors: Can't bind to 'ngforOf' since it isn't a known property of 'ion-col'. 1. If 'ion-col' is an Angular component and it has 'ngforOf' input, then verify that it is part of this module. 2. If 'ion-col' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message.

+0

ngFor. 각도 1을 2로 변환하려고합니다. 문법에 무엇이 빠져 있습니까? 도움을 주셔서 감사합니다 – Ennio

답변

0

당신은 당신의 코드가 다른에있는 경우 imports: [...]CommonModule을 추가 할 다른 방법이있는 경우 코드가 어디에 AppModuleimports: [...]BrowserModule를 추가하거나해야합니다

<ion-row> 
    <ion-col width-10 *ngFor="let x of deviceObj"> 
     <button ion-button outline icon-only small> 
     <ion-icon name="ios-add"></ion-icon> 
     </button> 
    </ion-col> 
    <ion-col width-10> 
     <button ion-button outline icon-only small [navPush]="setupPage"> 
     <ion-icon name="ios-add"></ion-icon> 
     </button> 
    </ion-col> 
    </ion-row> 

나는 그 말을 오류가 기준 치수.

오류 메시지는 NgFor 지시문이 모듈에 알려져 있지 않음을 의미합니다. CommonModule 또는 BrowserModule (AppModule 만)을 가져 오면 사용할 수 있습니다.

+0

정보를 주셔서 감사합니다, 내가 가지고있는 수입을 추가, 내가 누락되었습니다. – Ennio

관련 문제