My component html:
<div>
{{text}}
{{percentLeft}}
{{innerColor}}
</div>
My Component's TS File
import { Component,Input } from '@angular/core';
/**
* Generated class for the TimeLeftBarComponent component.
*
* See https://angular.io/docs/ts/latest/api/core/index/ComponentMetadata-class.html
* for more info on Angular Components.
*/
@Component({
selector: 'time-left-bar',
templateUrl: 'time-left-bar.html'
})
export class TimeLeftBarComponent {
@Input('text') text: string;
@Input('percentLeft') percentLeft: number;
@Input('innerColor') innerColor: string;
constructor() {}
}
How I call this component:
<time-left-bar [percentLeft]="50" [text]="text" [innerColor]="black">
</time-left-bar>
It's only displaying the first parameter I enter,
for Example:
<time-left-bar [percentLeft]="50" [text]="text" [innerColor]="black">
</time-left-bar>
Outputs just 50
<time-left-bar [text]="text" [innerColor]="black" [percentLeft]="50">
</time-left-bar>
Outputs just text
<time-left-bar [innerColor]="black" [percentLeft]="50" [text]="text">
</time-left-bar>
Outputs just black
What am I doing wrong?
public aNumber = 50and then in the view<time-left-bar [percentLeft]="aNumber" text="'text'" innerColor="'black'">? Sincetextand theinnerColorare just strings, you don't need the property binding (please notice that instead of sendingtextI send'text'with single quotes).