Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 角度2三分量数据传输_Angular_Input_Components_Output - Fatal编程技术网

Angular 角度2三分量数据传输

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

我有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" [(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
主题进行相同的操作示例如下: