div에 바인딩하는 방법에 대한 div id를 동적으로 바인딩 할 수 있습니다. 나는 attr.id와 [id] 등을 사용했지만 작동하지 않습니다. 제발 누군가가 나를 도울 수 있습니다.어떻게 내가 div2에 ID를 바인딩 할 수 있습니다 동적으로 C3을 js 차트에있는 div에 angular2
@Component({
selector: 'chart-component',
template: <h1>{{chartId}}</h1>
<div [id] = {{chartId}} class="c3"> </div>
})
export class ChartComponent implements OnInit
{
constructor(){ }
@Input('chartType') chartType:string;
@Input('chartId') chartId:Object;
@Input('chartData') chartData:any[];
ngOnInit() {
this.chartId = Object("chart1");
let chart = c3.generate({
bindto: '#'+this.chartId,
data: {
json:this.chartData,
type: this.chartType,
},
legend: {
show: true
}
});
}
}
(아래의 구성 요소 참조).
<chart-component chartType="bar" chartId="chart1" [chartData]="chartData">
div ID로 개체를 사용하려고했지만 여전히 작동하지 않습니다.
감사합니다,
아룬의
'chartData'를 추가 할 수 있습니까? – yurzui