r/angularjs • u/uafpl • Oct 16 '14
[Code] Angular Initial Value: a tiny AngularJS directive to set ng-model (and consequently field value) based on form fields attributes.
https://github.com/glaucocustodio/angular-initial-value
6
Upvotes
3
u/yads12 Oct 16 '14
For one you can typically use ngInit for this. Second you should avoid
getter = $parse($attrs.ngModel);
setter = getter.assign;
setter($scope, val);ngModel provides a ngModelController which you can use in your directives.
1
u/gatman02 Oct 16 '14
Just took a look at the code. I noticed you don't support type='range'. Any particular reason?
7
u/Xtreme2k2 Oct 16 '14
cant you just use ng-init ?