I have an angular object item.add_value = 0 bind into the
I think, the most best approach is in using ngModelController because it is not uses DOM (we just in data layer, not in view, we need bind as usual except 0) and very strait-forward. It helps adjust binding between model and it's view in way we need:
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.name = 'World';
});
app.directive('hideZero', function() {
return {
require: 'ngModel',
link: function(scope, element, attrs, modelCtrl) {
modelCtrl.$parsers.push(function (inputValue) {
if (inputValue === 0) {
return '';
}
return inputValue;
});
}
}
});
See more https://docs.angularjs.org/api/ng/type/ngModel.NgModelController.
Working plunker http://plnkr.co/edit/Zatou8lLx23xwXd1x9hd?p=preview.