javascript - Angularjs scope update issue -
i new angularjs. facing problem below markup like:
<div class="data-list"> <ul ng-repeat="client in clients | orderby:orderprop | filter:query"> <li><a ng-click="update(client)" data={{client.id}} href="#">{{client.name}}</a></li> </ul> </div> <div class="clientid"> {{clientid}} </div> and controller like:
function clientlistctrl($scope, $http) { $http.get('/dummy-data/clients.json', { cache: false }).success(function (data) { $scope.clients = data.clients; }); $scope.activeclient = {}; $scope.update = function (selectedclient) { $scope.activeclient = angular.copy(selectedclient); console.log($scope.activeclient); } console.log("after click"); console.log($scope.activeclient); // sorting list $scope.orderprop = '-numberofusers'; } i want when user click "client name", {{clientid}} updated, scope updates self. , return {} (blank object).
how can {{clientid}} after clicking clientname?
thanks in advance.
you controller not have property clientid , ng-repeat scoped <ul> tags.
change
<div class="clientid"> {{clientid}} </div> to
<div class="clientid"> {{activeclient}} </div>
Comments
Post a Comment