Angular 2 expression parser and ng-init directive

后端 未结 2 1119
没有蜡笔的小新
没有蜡笔的小新 2021-01-17 11:01

Basically I\'m looking for a way to implement a counterpart to Angular 1.x ngInit directive.

I\'m aware of ngOnInit hook and the fact that

2条回答
  •  孤城傲影
    2021-01-17 11:17

    This can be achieved with a directive:

    @Directive({ selector: '[initialize]' })
    class InitializeDirective {
      @Output() initialize = new BehaviorSubject();
    }
    

    The expected use is:

    {{ foo }} {{ bar }}

提交回复
热议问题