1
각과 이온으로 작성된 전화 갭 앱에 대한 토글 그룹이 있습니다. 기본 세트는 다음과 같습니다. HTML :각 이오니아 토글 그룹
<div ng-controller="LoginCtrl">
<h2 class="title">Items</h2>
<ion-toggle ng-repeat="item in riderList"
ng-model="selectedRider"
ng-checked="item.checked"
ng-change=" updateRider();"
data-rider-id="{{ item.id }}"
>
{{ item.text }}
</ion-toggle>
<button class="button button-full button-positive" id="zpass-logout">
Logout
</button>
</div>
및 JS :
angular.module('zpassApp')
.controller('SettingsCtrl', ['$scope', '$http', '$rootScope', '$location',
function($scope, $http, $rootScope, $location) {
$scope.riderList = [];
$scope.addRider = function(name, id, active) {
$scope.riderList.push({ "text" : name, "checked" : active , "id" : id});
$scope.$apply();
};
$scope.updateRider = function() {
console.log("in update rider how do I get the item.id!?");
// I expect this to be selectedRider.id, but that is undefined
// in jquery would be $(this)..data('id');
}
function getRidersFromDB() {
// this just queries db an populates, works fine...
}
이없는 것이 변경되었습니다 토글의 ID와 상태로 얻을 수 있습니다. 이 작업을 수행하는 올바른 방법은 무엇입니까?