我是 angularjs 的新手。面临如下问题我的标记就像:
<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>
我的控制器就像:
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);
// for sorting list
$scope.orderProp = '-numberOfUsers';
}
我希望当用户单击“客户端名称”时{{clientId}}
会更新,但范围会自行更新。并返回{}
(空白对象)。
单击客户端名称后如何获取 {{clientId}}?
提前致谢。