I have a directive that has range inputs inside of it and I need to
dynamically set the min max and step size, which will come from the parent
directives scope. For some reason everything seems to work fine until I try
to set the step value, in which case I think it's still using the default
value. I was able to find a work around by setting the step attribute
directly using jquery syntax, but if anyone has insight into why my
original approach might not be working I would really love to know. Is this
a bug, or am I just fighting angular?
Below is a simplified example of what I am doing. If you uncomment the last
line it works as expected.
angular.module('myApp',[]);
angular.module('myApp')
.directive('inputDir', function() {
return {
template: '<input ng-model="value" type="range" ng-attr-max="{{max}}"
ng-attr-min="{{min}}" ng-attr-step="{{step}}">{{value}}',
restrict: 'E',
scope: {},
link: function(scope, element, attrs) {
var range = element.find('input');
scope.value = 0.25;
scope.max = 1;
scope.min = 0;
// This fails
scope.step = 0.01;
// This works
//range.attr('step', 0.001);
}
};
});
I have created a jsbin to edit as well.
http://jsbin.com/veporozi/1/edit?html,js,output
Thanks in advance for any help!
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.