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();
});
}]);