0
我的ng-repeat中有input field
match in matchList
。我希望能夠點擊輸入字段並顯示這個複選框被點擊的次數。它正在工作,但有一個問題。AngularJS - 專注於ng-repeat中的輸入字段
當我點擊輸入字段時,焦點從0-1開始計數,但是對於每個對象,都有ng-repeat
。我只想顯示點擊輸入字段的計數。所以我需要給輸入字段一個ng-model來得到點擊的輸入字段數。
這是我的NG-重複我的輸入字段:
<input ng-model="??" ng-focus="focusEvent()" type="number" min="0" max="9" step="1" ng-value="'{{ match[2] }}'">
這是我的控制器:
app.controller('gametableController', ['currentAuth', '$scope', '$location', '$firebaseObject', '$firebaseArray', '$http', 'cfpLoadingBar', function (currentAuth, $scope, $location, $firebaseObject, $firebaseArray, $http, cfpLoadingBar) {
$scope.versus = 'VS';
$scope.onMobileInfo = 'Der Spielplan wird nur auf einem größeren Bereich angezeigt.';
$scope.timesFocused = 0;
$scope.isFocused = false;
var ref = firebase.database().ref("matches");
var matchList = $firebaseObject(ref);
matchList.$loaded().then(function() {
cfpLoadingBar.start();
$scope.matchList = [];
angular.forEach(matchList, function (match) {
var matchTeams = [];
angular.forEach(match, function (team) {
matchTeams.push(team)
});
$scope.focusEvent = function() {
$scope.timesFocused++;
};
$scope.focusInput = function() {
$scope.isFocused = !$scope.isFocused;
};
$scope.matchList.push(matchTeams);
});
cfpLoadingBar.complete();
});
}]);