I figured out the error. Although the $setViewValue
should have set my form to dirty, the thing which was stopping it was the fact that the code where I was doing this was out-of-$scope
;)
And, for that the $scope.$apply()
comes in handy. So, now along with the model, I'm also passing in the $scope to the polyfill.
angular.module('appModule').
directive('type', ['$parse', '$timeout', function($parse, $timeout) {
restrict: 'A',
require: '?ngModel',
link: function($scope, iElement, iAttrs, ngModel) {
...
if iAttrs.type is 'number'
iElement.inputNumber(ngModel, $scope) // <-- THIS LINE
...
}
}
increment = function(elem) {
...
if (model != null) {
$scope.$apply(function() {
model.$setViewValue(newVal);
}
}
...
}