属性在类型上不存在 [英] Property does not exist on type
本文介绍了属性在类型上不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在与Ionic2和Angular2合作开展一个项目。尝试运行 ionic serve
时,将检索数据而不会出现任何错误。但是,当尝试在ios上运行并运行 ionic build ios
时,我收到以下编译时错误,该属性不存在。
I am working on a project with Ionic2 and Angular2. When trying to run ionic serve
, the data is retrieved without any errors. However, when trying to test on ios and running ionic build ios
, I am getting the below compile time errors, that properties do not exist.
还有其他人遇到过这个问题吗?
Has anyone else encountered this issue?
我感谢任何建议。
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
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
推荐答案
不要使用这个
在视图绑定中
{{ this.data.name }}<
应该是
{{ data.name }}<
这篇关于属性在类型上不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文