私は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}}
すると更新されますが、スコープはそれ自体を更新します。そして戻る{}
(空白のオブジェクト)。
clientName をクリックした後に {{clientId}} を取得するにはどうすればよいですか?
前もって感謝します。