0

Is it possible to add multiple values to property in ngStyle directive? like for example:

<div [ngStyle]='{"background" : ["rgba(248,80,50,1)", "-webkit-gradient(left top, right top, color-stop(0%, rgba(248,80,50,1)), color-stop(50%, rgba(241,111,92,1)), color-stop(51%, rgba(246,41,12,1)), color-stop(71%, rgba(240,47,23,1)), color-stop(100%, rgba(231,56,39,1)))"]}' ></div>

Thanks

Emmanuel Villegas
  • 1,374
  • 3
  • 12
  • 19

1 Answers1

1

In this example couldn't you just use a custom class? In your component definition you can include a unique stylesheet for that particular component with styleUrls. Example:

@Component({
selector: 'my-component',
moduleId: module.id,
templateUrl: 'my-component.html',
styleUrls: ['my-component.css'] // <-- here
})

Another way it might be easier to use ngClass if you need to toggle different styles as well.

Mickers
  • 1,367
  • 1
  • 20
  • 28
  • thanks for your replay, i need to load the styles dinamically, so i think the ngClass directive can´t do that, same with stylesUrl. – Emmanuel Villegas Nov 10 '16 at 18:36
  • I see. I didn't grasp that from your example. I did find an [example](http://stackoverflow.com/questions/21364445/apply-css-style-attribute-dynamically-in-angular-js) of how to do it with Angular 1. Perhaps you can translate it to Angular 2 to do what you want. Hope that helps. – Mickers Nov 10 '16 at 20:41