Can't seem to get Angular formatters and parsers working:
app.js:
var itemApp = angular.module('itemApp', []);
itemApp.controller('ItemController', ['$scope', function($scope) {
$scope.some_value = 'abcEFG';
}]);
itemApp.directive('changeCase', function () {
return {
restrict: 'A',
require: 'ngModel',
link: function (scope, element, attrs, ngModel) {
ngModel.$formatters.push(function(value){
return value.toUpperCase();
});
ngModel.$parsers.push(function(value){
return value.toLowerCase();
});
}
};
});
view.html:
<input ng-model="some_value" changeCase>
It doesn't work- no errors, just nothing happens to the values in the input or the model. I'm newish to Angular, having trouble figuring out how I'd even debug this.