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

angular – 什么是数据绑定属性?

发布时间:2020-12-17 07:51:15 所属栏目:安全 来源:网络整理
导读:我试图理解angular2中的OnInit功能并阅读文档: Description Implement this interface to execute custom initialization logic after your directive’s data-bound properties have been initialized. ngOnInit is called right after the directive’s d
我试图理解angular2中的OnInit功能并阅读文档:

Description

Implement this interface to execute custom initialization logic after
your directive’s data-bound properties have been initialized.

ngOnInit is called right after the directive’s data-bound properties
have been checked for the first time,and before any of its children
have been checked. It is invoked only once when the directive is
instantiated.

我不明白指令的数据绑定属性是什么意思?

当你有一个组件
@Component({
  selector: 'my-component'
})
class MyComponent {
  @Input() name:string;

  ngOnChanges(changes) {
  }

  ngOnInit() {
  }
}

你可以像使用它一样

<my-component [name]="somePropInParent"></my-component>

这使名称成为数据绑定属性.

更改somePropInParent的值时,Angulars更改检测更新名称并调用ngOnChanges()

在第一次调用ngOnChanges()之后,调用ngOnInit()一次,以指示解析并应用了初始绑定([name] =“somePropInParent”).

有关详细信息,请参阅https://angular.io/docs/ts/latest/cookbook/component-communication.html

(编辑:李大同)

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

    推荐文章
      热点阅读