user7052596
user7052596

Reputation:

ng model not working

I am trying to set the value using ng-model (passing values via function).

My codes look like

Input tag:

   <input name="comments" ng-model="comments" class="form-control" type="text">

Grid Table :

  <tr ng-repeat="value in values">
   <td><input type="radio" ng-click="callvalues(value.CUSTID);"></td>

Angularjs code:

$scope.callvalues = function($scope,custID){
     alert("custID");
};

I am getting custID is not defined. I try to hardcore values

 $scope.callvalues = function($scope,custID){
      $scope.comments = "122";
};

NO error in console but it's also not working.

Upvotes: 0

Views: 275

Answers (4)

manoj kumar c.a
manoj kumar c.a

Reputation: 146

remove $scope parameter from your function from $scope.callvalues = function($scope,custID){ to $scope.callvalues = function(custID){

Upvotes: 1

Akashii
Akashii

Reputation: 2281

If what you mean is click in radio button and alert value you can try this code

$scope.callvalues = function(custID){
     alert(custID);
    $scope.comments = custID;
};

plnkr

https://plnkr.co/edit/CYi3e2D0xLkWksr9p4y8?p=preview

Upvotes: 0

Beri
Beri

Reputation: 11600

You don't need to pass $scope as method argument. You can read it's values in any method inide of Controller.

$scope.callvalues = function(custID){
     alert("custID");
     $scope.comments = custID;
};

Upvotes: 0

Praveen Kumar
Praveen Kumar

Reputation: 138

Grid Table

<tr ng-repeat="value in values">
<td><input type="radio" ng-model="selectedRadio" ng-value="value.CUSTID" ng-click="callvalues(selectedRadio);"></td>

Controller

$scope.callvalues = function(custID){
 //console.log($scope.selectedRadio); 
 alert(custID);
};

Upvotes: 0

Related Questions