【发布时间】:2016-07-11 14:29:26
【问题描述】:
我正在尝试编写自定义指令来传递输入值,然后将数据绑定到迷你图,但它给了我错误:
迷你图不是函数。
下面是plunker:
import { Directive, ElementRef, HostListener, Input , OnInit } from '@angular/core';
@Directive({
selector: '[myBarChart]'
})
export class BarChartDirective {
private el: HTMLElement;
@Input('myBarChart') barChartValues: number[] = [];
constructor(el: ElementRef) { this.el = el.nativeElement; }
ngOnInit() {
this.el.sparkline(this.barChartValues, {
type: 'bar', barColor: 'green', width: 300, height: '50',
barWidth: 8, barSpacing: 3, colorMap: ["green", "yellow", "red"],
chartRangeMin: 0
});
}
}
【问题讨论】:
标签: angular angular2-directives sparklines