2017-01-21 9 views
1

アプリケーションのTSファイルにオブジェクトの配列があります。ストレージから取得しているオブジェクトを配列に取り込んでいます。私のhtmlファイルにイオン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ファイル上のコードで取得します。

<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> 

私はそれを言ってエラーを取得:

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。私はangular1を2に変換しようとしています。シンタックスには何が欠けていますか?助けてくれてありがとう – Ennio

答えて

0

あなたはあなたのコードがどこにあるか、これがあればAppModuleimports: [...]BrowserModuleを追加する必要がある、またはあなたのコードは別のものである場合、代わりimports: [...]CommonModuleを追加モジュール。

エラーメッセージは、NgForディレクティブがモジュールで認識されていないことを意味します。 CommonModuleまたはBrowserModuleAppModuleのみ)をインポートすると利用可能になります。

+0

感謝の気持ち、私が持っている輸入品を追加しました。 – Ennio

関連する問題