Hi everyone,
I'm pretty new to Angular, so bear with me.
I have an input field (Company) where the user can write a company name, 
and as the user types (change()) I make a $http look-up in an VATapi to 
find the corresponding VAT number (8 characters).
When I find the right number I would like to update another input field 
(VATnr.) with this value. The problem is, that when I put 

ng-minlength=8 ng-maxlength=8 


on the VATnr. input field the number is not updated in the (VATnr.) input 
field. I've also tried 

ng-minlength="8" ng-maxlength="8" 



This is the code
//THE TWO INPUT FIELDS
<input type="text" name="company" placeholder="Indtast firmanavn" ng-model=
"user.company" ng-change="checkCVR()" ng-keydown="cvrKeyDown($event)" 
required>

<input type="text" name="cvr" placeholder="Indtast virksomhedens CVR.nr." 
ng-model="user.cvr" ng-minlength=8 ng-maxlength=8 integer required>




//THE CONTROLLER
$scope.checkCVR = function()
      {

      $http.jsonp('http://cvrapi.dk/api?callback=JSON_CALLBACK&search=' + 
$scope.user.company + '&country=dk')
      .success(function(data, status, headers, config) 
       {
       $scope.compnay_name = data.name;
       $scope.compnay_vat = data.vat;


})
      }

            

      $scope.cvrKeyDown = function($event)
      {
      if($event.keyCode == 13)
      {
      $event.preventDefault();
      $scope.user.cvr = $scope.compnay_vat;
      }


      }


      $scope.updateCVRvat = function()
      {
      $scope.user.cvr = $scope.compnay_vat;
      }



Also, I would like to make the CVRnr input field only validate, when the 
user types in numbers. I cannot use the type="number" attribute.


Thanks guys.
Kasper

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to