We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
这算是 Angularjs1.x 与 Angular2 一个重大的区别了,切换到 Angular2 编程还真有点适应不过来,不过用起来发现,Angular2 的通讯方式语义更清楚,协作起来更方便。
这种方跟 Angularjs1.x 的方式私以为无差异
directives: [Child]
[content]="i"
{{content}}
这种方式基于事件
@Output() updateNumberI:EventEmitter<number> = new EventEmitter();
(updateNumberI)="numberIChange($event)"
this.updateNumberI.emit(++this.i);
@ViewChild(Child) child:Child;
{{service.i}}
这种方式在 Angular1.x 中用的也比较多,只不过那时候用的是 $rootscope 上的方法。
kittencup/angular2-ama-cn#23
The text was updated successfully, but these errors were encountered:
话说哪几种方式比较好呢,或者适应的场景是什么?
Sorry, something went wrong.
No branches or pull requests
这算是 Angularjs1.x 与 Angular2 一个重大的区别了,切换到 Angular2 编程还真有点适应不过来,不过用起来发现,Angular2 的通讯方式语义更清楚,协作起来更方便。
通讯方式
父->子 input 方式(已淘汰)
这种方跟 Angularjs1.x 的方式私以为无差异
directives: [Child]
[content]="i"
{{content}}
子->父 output 方式
这种方式基于事件
@Output() updateNumberI:EventEmitter<number> = new EventEmitter();
(updateNumberI)="numberIChange($event)"
this.updateNumberI.emit(++this.i);
父获得子实例
@ViewChild(Child) child:Child;
service 方式
{{service.i}}
service EventEmitter方式
这种方式在 Angular1.x 中用的也比较多,只不过那时候用的是 $rootscope 上的方法。
参考
kittencup/angular2-ama-cn#23
The text was updated successfully, but these errors were encountered: