[英]How to pass a String[] to my angular2 html template
I have an array variable declared in the export class of my component; 我在组件的导出类中声明了一个数组变量;
barChartLabel:string[] = ['2006', '2007', '2008', '2009', '2010', '2011', '2012'];
I display this to the screen in my html template as follows 我将其显示在我的html模板中的屏幕上,如下所示
{{barChartLabel}}
but when i put that into a parameters value it fails, as follows 但是当我将其放入参数值时,它失败,如下所示
<mychart [chartLabelObject]="[{{barChartLabel}}]"></mychart>
Any idea what im doing wrong? 知道我在做什么错吗?
I think what you are trying to do is pass this to a child component (mychart)? 我认为您正在尝试将其传递给子组件(mychart)?
in your child component.ts : 在您的子component.ts中:
import { Input } from '@angular/core';
export class app {
@Input() chartLabelObject:string[];
}
parent .component.html: 父.component.html:
<app-craftinput [chartLabelObject]="barChartLabel"></app-craftinput>
https://angular.io/docs/ts/latest/cookbook/component-communication.html https://angular.io/docs/ts/latest/cookbook/component-communication.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.