2

I facing one issue while doing a app with angular material design, when using a slider there is no attribute for set default value. currently there is some attribute like 'step', 'min' and 'max'. I looking for a attribute like 'default', so I can set default value between the range for an on load. Please suggest a solution.

<md-slider md-discrete ng-model="myDiscreteValue" step="10" min="10" max="130">

2 Answers 2

3

I think you just need to give your scope's myDiscreteValue variable a value when your controller is loading.

0

Try the following, set your $scope.myDiscreteValue to the value you want by default.

.controller('YourController', ['$scope', function ($scope) {
    $scope.myDiscreteValue = 5; //Will set the slider to a value of 5
}]);
1
  • 1
    What if you just want to use Angular Material on the page without creating a custom controller. The goal of Angular Material, is to avoid needing to customize controllers for everything, and just work directly in HTML. We are told not to use ng-init but aren't given a lot of other options. Commented May 14, 2019 at 10:24

Not the answer you're looking for? Browse other questions tagged or ask your own question.