Reputation: 3
I am looking for setting dynamic css for [ngStyle] from my component ms-toolbar I have set html as
<md-toolbar class="ms-toolbar" [ngStyle]="StylingToolbar">
</md-toolbar>
and from ts I have initialize as
export class AppbarComponent {
StylingToolbar = {
'background-color': '00bcd4',
'color':'white'
};
}
But on rendering it is not working. On rendering It is setting element as
<md-toolbar _ngcontent-alm-42="" class="ms-toolbar" ng-reflect-ng-style="[object Object]">
I am using Angular version 2.3.1
Please suggest some better way to do this.
Upvotes: 0
Views: 1085
Reputation: 317
What you have did is right just check your object code
You need to add # before color code
Use below code
export class AppbarComponent {
StylingToolbar = {
'background-color': '#00bcd4',
'color':'white'
};
}
Upvotes: 1