小编5tk*_*tka的帖子

什么是@Input()用于?

我决定学习Angular 4并按照https://angular.io/tutorial/toh-pt3上的教程进行操作.但是,问题又出现了.这是什么

@Input () hero: Hero; 
Run Code Online (Sandbox Code Playgroud)

它是为了什么?它有什么作用?这是什么意思?

这是代码.英雄details.component.ts

import { Component, Input } from '@angular/core';
import { Hero } from "./hero";


@Component({
 selector: 'hero-detail',
 templateUrl: './hero-detail.component.html'
})
export class HeroDetailComponent {
 @Input() hero: Hero;
}
Run Code Online (Sandbox Code Playgroud)

下面是对文件的另一个代码app.components.ts,app.components.html,hero-details.components.html

如果有人可以,请解释一下

typescript angular

37
推荐指数
4
解决办法
4万
查看次数

标签 统计

angular ×1

typescript ×1