如何识别Angular 4中相同类型的渲染组件?
我有一个名为clock.component.ts的组件和一个仪表板,我在其中多次调用时钟。 在控制面板中,从数据库调用分配给用户的跑步者,如果用户有3个指定的跑步者,则他将渲染clock.3次。如何识别每个道路的id或将其发送到其各自的组件 这在dashboard.component.html中如何识别Angular 4中相同类型的渲染组件?,angular,Angular,我有一个名为clock.component.ts的组件和一个仪表板,我在其中多次调用时钟。 在控制面板中,从数据库调用分配给用户的跑步者,如果用户有3个指定的跑步者,则他将渲染clock.3次。如何识别每个道路的id或将其发送到其各自的组件 这在dashboard.component.html中 <app-clock *ngFor="let corredor of runnerList"></app-clock> 您可以通过向组件添加和输入来实现这一点 import {
<app-clock *ngFor="let corredor of runnerList"></app-clock>
您可以通过向组件添加和输入来实现这一点
import { Component, OnInit,Input } from '@angular/core';
@Component({
selector: 'app-clock',
templateUrl: './clock.component.html',
styleUrls: ['./clock.component.css']
})
export class ClockComponent implements OnInit {
@Input() idCorredor; //This is the id that I need
constructor() { }
ngOnInit() {
}
startClock(){
}
}
并以这种方式分配输入
<app-clock *ngFor="let corredor of runnerList" [idCorredor]="corredor.id"></app-clock>
<app-clock *ngFor="let corredor of runnerList" [idCorredor]="corredor.id"></app-clock>