Mishu Lojan Mishu Lojan - 15 days ago 9
AngularJS Question

Ng-change not working properly in angularjs

I'm using a input type= number , but I cannot get my ng-change function to call.

<input type="number" name="numero" placeholder="1234 1234 1234 1234" ng-model="card.numero" ng-change="validar_card()" required>


my controller

$scope.validar_card=function () {
console.log(card.numero);
}

Answer

In your controller you forgot to put $scope in your console.log:

console.log($scope.card.numero);

Also dont forget to put $scope.card = {} in the beggining of the controller. Below fiddle:

http://jsfiddle.net/twizzlers/5f411u2e/1/