2016-11-14 25 views
2

私はIonic2とAngular2のプロジェクトに取り組んでいます。 ionic serveを実行しようとすると、エラーなしでデータが取得されます。しかし、iOSでテストしてionic build iosを実行しようとすると、以下のコンパイル時にエラーが発生します。そのプロパティは存在しません。プロパティがタイプに存在しません

他に誰かがこの問題を抱えていますか?

私は何か提案をいただきありがとうございます。

home.ts

import { Component } from '@angular/core'; 
import { ProfileService } from './profile.service'; 

@Component({ 
    selector: 'home', 
    templateUrl: 'home.html', 
    providers: [ProfileService] 
}) 
export class HomePage { 

    constructor(public d: HomeService){ 
     this.loadData(); 
    } 

    loadData() { 
    this.d.fbPromise.then((FB) => this.data.getData(FB)).then(response => { 
     this.data = response; 
    }); 
    } 
} 

home.html

<ion-header> 
    <ion-navbar> 
     <ion-title>Home</ion-title> 
    </ion-navbar> 
</ion-header> 

<ion-content> 

    <div class="profile-content" padding> 
     <div class="content-header"> 
      <h2 class="name">{{ this.data.name }}</h2> 


     <div class="interests-content"> 
      <h3>interests</h3> 

      <span *ngFor="let interest of this.data.interests" > 
       {{ interest.title }} : {{interest.name}} 
      </span> 
     </div> 
    </div> 
</ion-content> 

コンパイル時エラー:

[10:10:18] Error: Error at /Users/zzz/Sites/angular-app/Flah/.tmp/pages/home/home.ngfactory.ts:330:47 
[10:10:18] Property 'name' does not exist on type 'HomeService'. 
[10:10:18] Error at /Users/zzz/Sites/angular-app/Flah/.tmp/pages/home/profhomeile.ngfactory.ts:349:72 
[10:10:18] Error at /Users/zzz/Sites/angular-app/Flah/.tmp/pages/home/phomerofile.ngfactory.ts:354:72 
[10:10:18] Property 'interests' does not exist on type 'HomeService'. 
[10:10:18] ngc failed 
[10:10:18] ionic-app-script task: "build" 
[10:10:18] Error: Error 
+0

すべきですか? –

+0

@GünterZöchbauer、テンプレートを追加しました。 – AnchovyLegend

答えて

6

ビューバインディング

{{ this.data.name }}< 
thisを使用しないでください。

あなたは `HomeService.name`にアクセスしようとしたん

{{ data.name }}< 
+0

提案していただきありがとうございます。私はこれらの変更を加えましたが、現在ははるかに洗練されていますが、ios用にビルドしようとすると同じエラーが発生します。ここでもまた、「ionic serve」はうまく動作しますが、「ionic build ios」はコンパイル時に上記のエラーを生成します。 – AnchovyLegend

+0

'' this.data.getData(FB) 'で ''応答' 'と思っています。(返答=> {'はあなたの期待通りではありません) –

+0

' 'ionic serve' 、responseオブジェクトを利用していますか? – AnchovyLegend

関連する問題