加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Angular 4模板错误:’anonymous’不包含这样的成员

发布时间:2020-12-17 07:16:05 所属栏目:安全 来源:网络整理
导读:Angular 4用Typescript 2.3.4编写 component.ts /** * Info that drives the tabs in the template. Array is filled * in ngOnInit() once data is received from the server */public tabs:Array{ title:string,description:string,data:Array{name:string
Angular 4用Typescript 2.3.4编写

component.ts

/**
 * Info that drives the tabs in the template. Array is filled
 * in ngOnInit() once data is received from the server
 */
public tabs:Array<{
  title:string,description:string,data:Array<{name:string}>
}>=[];

component.html

<section *ngFor="let t of tabs">
  ...
  <div *ngFor="let i of t.data">{{i.name}}</div>
                                  ^^^^^^
</section>

编译错误

Angular: Identifier ‘name’ is not defined. <anonymous> does not contain such a member

起初我认为这与my other issue有关,但这是不同的,因为tab模型的形状没有歧义:组件清楚地表明name是数据数组的每个成员的属性,本身是每个成员的属性. tabs数组.

这里发生了什么?

解决方法

解决方案有效
这给了我这样的信息:

Identifier ‘question’ is not defined. ” does not contain such a member

加上强调这一点

<div class="card-header">
          {{q.question}}  <!- underline this line with red color -->
            ^^^^^^^^^^
</div>

这是一个打字稿问题,您必须将标签声明为任何类型以避免此问题标签:any [];

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读