Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/28.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 将查询中的新数据传递到子组件中_Angular - Fatal编程技术网

Angular 将查询中的新数据传递到子组件中

Angular 将查询中的新数据传递到子组件中,angular,Angular,在Angular中,当您从API获取数据时,是否将数据传递给子组件?我无法将新数据从查询传递到子组件。这可以通过多种方式完成。其中之一是在子组件中使用@Input()装饰器。您的子组件具有一个属性,并且父组件在每次收到api响应时都会更改此属性 ChildComponent export class ChildComponent implements OnInit { @Input() testProp; constructor() {} ngOnInit() {} } Pare

在Angular中,当您从API获取数据时,是否将数据传递给子组件?我无法将新数据从查询传递到子组件。

这可以通过多种方式完成。其中之一是在子组件中使用
@Input()
装饰器。您的子组件具有一个属性,并且父组件在每次收到api响应时都会更改此属性

ChildComponent

export class ChildComponent implements OnInit {
  @Input() testProp;
  constructor() {}

  ngOnInit() {}
}
ParentComponent

export class ChildComponent implements OnInit {
  @Input() testProp;
  constructor() {}

  ngOnInit() {}
}
在html中

<app-child testProp="{{value}}"></app-child>

您想将响应从API传递到子组件还是通过路由查询传递数据?我想将响应从API传递到子组件,并且我想重复从API请求新响应以更新子组件中的数据状态