angularjs - Issues indirectly updating ngModel from ngClick -


i have ngrepeat populates list of customers, shown here :

<div ng-repeat="terr in terrdata.data">     <div class="customer-row" ng-click="clickcustomerselect(terr)">         <input class="customer-radio" type="radio" name="customer-select" ng-model="selectedcustomerrow" value="{{terr.customerid}}">         <div class="contact-data-column">{{terr.custnm}}</div>           <div class="primaryphone-data-column">{{terr.primaryphone}}</div>         <!-- other customer data -->     </div> </div> 

there click event on customer-row div says if row clicked, radio button row should checked.

the basic controller logic shown here :

$scope.clickcustomerselect = function(customer){     $scope.selectedcustomerrow = customer.customerid.tostring();     //other business logic }; 

i see whenever customer row clicked (not radio button), model gets updated, , radio button corresponding value checked. note expected functionality.

the issue i'm seeing if check radio button manually (i.e. not clicking row), model no longer respond updates clicking row.

i'm wondering if somehow once select radio button you're going outside of angular scope?

edit: sample model

terrdata.data = [{     "customerid": 1,     "companyname": "name 1",     "custnm": "blank",     "primaryphone": "111-111-1111" }, {     "customerid": 2,     "companyname": "name 2",     "custnm": "blank",     "primaryphone": "111-111-1112" }, {     "customerid": 3,     "companyname": "name 3",     "primaryphone": "111-111-1113" }]; 

  $scope.selectedcustomerrow = customer.customerid.tostring(); 

replace to:

 $scope.selectedcustomerrow = customer.customerid; 

onclick set selectedcustomerrow.

in html

 <input class="customer-radio" type="radio" name="customer-select" ng-model="selectedcustomerrow" value="{{terr.customerid}}"> 

replace to:

  <input class="customer-radio" type="radio" name="customer-select" ng-model="$parent.selectedcustomerrow" value="{{terr.customerid}}"> 

demo


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -