I have this directive to increment and decrement variable like this
angular.module('shopping')
.directive('myDir', function () {
return {
restrict: 'AE',
scope: {
dirModel: '='
},
template: '<div><button ng-click="decrement()">-</button>' +
'<div ng-model="dirModel">{{ value }}</div>' +
'<button ng-click="increment()">+</button></div>',
link: function (scope, iElement, iAttrs) {
scope.increment = function () {
scope.value += 20;
}
scope.decrement = function () {
scope.value -= 20;
}
}
};
});
I am using like this
<my-dir dirModel="user.interval"></my-dir>
Now when i click on edit form where my scope already have user.interval = 30 then that does not get set.
For new form it works ok
<div ng-model="dirModel">.ng-modelattribute should be on an input element (including selects and textareas), not a div