opendave opendave - 1 year ago 122
AngularJS Question

Gradients with Angular Material md-colors directive

I'm wondering if there is any way to do gradients using the Angular Material md-colors directive?


Answer Source

It doesn't seem possible with the md-colors directive but you can do it programatically - CodePen


<div ng-controller="AppCtrl as ctrl" ng-cloak="" ng-app="MyApp" layout-fill layout-padding layout="column">
  <div style="background: linear-gradient({{ctrl.color1}}, {{ctrl.color2}})" flex></div>



.controller('AppCtrl', function($mdColors) {
  this.color1 = $mdColors.getThemeColor('primary-600');
  this.color2 = $mdColors.getThemeColor('primary-100');

Note that this won't work with IE. From the docs:

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download