'use strict';

app.directive('forceInteger', function() {
  return {
    restrict: 'A',
    require: 'ngModel',
    scope: {
      ngModel: '='
    },
    link: function(scope, element, attrs) {
      scope.$watch(function(){
        return scope.ngModel;
      }, function(){
          scope.ngModel = Number(scope.ngModel);
          console.log(scope.ngModel, typeof scope.ngModel);
      },true);
    }
  };
});



// app.directive('forceInteger', function(){
//   return {
//     restrict: 'A',
//     require: 'ngModel',
//     link: function(scope, element, attr, ngModelCtrl){
//       ngModelCtrl.$parsers.unshift(function(viewValue){
//         console.log(viewValue);
//         return parseInt(viewValue, 10);
//       });
//     }
//   };
// });