I am trying to apply a gradient to an element using angular but failing to do so with ngStyle
.
Here is an example of what I try to achieve: http://run.plnkr.co/plunks/mwJBcWaJ1hqOUCsSyy8a/
Old link, not working anymore http://run.plnkr.co/maDs3PSWw4Y5tDfb/
In the example I am using the plain style="{{css}}"
, which is not the recommended approach as described in the documentation (short version, step 5). It will not render in IE <= 11.
If I try to use ng-style="css"
and set up like this:
$scope.css = {
background: '-webkit-linear-gradient(' + gradient + ')',
background: '-moz-linear-gradient(' + gradient + ')'
…
}
You'll see the obvious problem, the css
object can just contain one instance of background
.
I cannot think of many instances where I'd have to browser-prefix like this. Does AngularJS address this in any way or is there a IE <= 11 solution?