gpt4 book ai didi

angular - 属性在类型上不存在

转载 作者:搜寻专家 更新时间:2023-10-30 21:17:53 24 4
gpt4 key购买 nike

我正在使用 Ionic2 和 Angular2 开发一个项目。当尝试运行 ionic serve 时,数据被检索而没有任何错误。但是,当尝试在 ios 上进行测试并运行 ionic build ios 时,出现以下编译时错误,即属性不存在。

有没有人遇到过这个问题?

我很感激任何建议。

首页.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;
});
}
}

主页.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

最佳答案

不要在 View 绑定(bind)中使用this

{{ this.data.name }}<

应该是

{{ data.name }}<

关于angular - 属性在类型上不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40592029/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com