Angular 角度2三分量数据传输
我有3个角度分量。Angular 角度2三分量数据传输,angular,input,components,output,Angular,Input,Components,Output,我有3个角度分量。 第一个是应用组件 第二个测试1.组件和 第三个test2.组件 app.component.html <app-test1 [(value)]="name" ></app-test1> <button (click)="click()">Save</button> <app-test2 [(value)]="value"></app-test2> <input type="test" [(ngM
第一个是应用组件
第二个测试1.组件和
第三个test2.组件 app.component.html
<app-test1 [(value)]="name" ></app-test1>
<button (click)="click()">Save</button>
<app-test2 [(value)]="value"></app-test2>
<input type="test" [(ngModel)]="value">
我不想输出。使用rxjs主题道具创建一个服务,并将其注入到app和test2中
//在役财产
inputUpdate = new Subject()
在测试2中
//在构造函数中注入服务
<input type="test" (change)="someService.inputUpdate.next($event)>
使用rxjs Subject prop创建一个服务,并将其注入到app和test2中
//在役财产
inputUpdate = new Subject()
在测试2中
//在构造函数中注入服务
<input type="test" (change)="someService.inputUpdate.next($event)>
您可以使用RxJs
主题进行相同的操作,示例如下:您可以使用RxJs
主题进行相同的操作示例如下: