mercredi 14 juin 2017

Reverse checkbox value in angular2

Having some troubles reversing the checkbox value in Angular 2.

In Angular 1.x we could make a directive like below.

.directive('invertValue', function() { return { require: 'ngModel', link: function(scope, element, attrs, ngModel) { ngModel.$parsers.unshift(function(val) { return !val; }); ngModel.$formatters.unshift(function(val) { return !val; }); } }; })




Aucun commentaire:

Enregistrer un commentaire