0
から個々の入力フィールドにアクセス$ scope.enteredSequenceであり、これらの入力ボックスのそれぞれから値をその配列にプッシュしたいとします($ scope.enteredSequence = ["Patkar"、 "Janub"、 "Stubbi"、 "Wolle"])Angularjsは私のHTMLにコードを次しているリスト
どうすればいいですか?
.controller('DashCtrl', function($scope, $timeout) {
$scope.level=1
$scope.leftList=false
$scope.enterTextView=false
$scope.previewView=false
$scope.promptAction=''
$scope.promptLevel=''
$scope.enteredSequence= [];
$scope.expectedSequece=[]
$scope.show_stop_button=false
$scope.show_start_button=true
$scope.word_pair = [
{'word':'Nitish', 'pair':'Patkar'},
{'word':'Mihir', 'pair':'Janaj'},
{'word':'Jannes', 'pair':'Stubbi'},
{'word':'Martin', 'pair':'Wolle'}
]
$scope.partnerCheckList = {};
for(var v in $scope.word_pair){
$scope.expectedSequece.push($scope.word_pair[v].pair)
console.log($scope.expectedSequece)
$scope.partnerCheckList[$scope.word_pair[v].word] = $scope.word_pair[v].pair;
}
$scope.showPartner = {};
$scope.partnerCheck = function(p,i_p){
$scope.enteredSequence.push(p)
console.log($scope.enteredSequence)
if($scope.partnerCheckList[i_p] == p){
$scope.showPartner[p] = true;
}
}
$scope.start = function(){
$scope.show_start_button=false
$scope.leftList=true
$scope.previewView=true
$scope.promptLevel='Level: ' + $scope.level
$scope.counter1=5
$timeout($scope.startFilling, 5000)
$scope.onTimeout = function(){
$scope.counter1--;
mytimeout = $timeout($scope.onTimeout,1000);
if($scope.counter1==0){
$timeout.cancel(mytimeout);
}
}
var mytimeout = $timeout($scope.onTimeout,1000);
}
$scope.startFilling = function(){
$scope.promptLevel='Level: ' + $scope.level
$scope.promptAction='Now enter the corresponding pairs in the right column'
$scope.enterTextView=true
$scope.previewView=false
$scope.show_start_button=false
$scope.show_stop_button=true
$scope.counter2=20
$timeout($scope.checkCorrectness, 20000)
$scope.onTimeout = function(){
$scope.counter2--;
mytimeout = $timeout($scope.onTimeout,1000);
if($scope.counter2==0){
$timeout.cancel(mytimeout);
$scope.enterTextView=false
$scope.previewView=false
$scope.leftList=false
$scope.show_stop_button=false
$scope.show_start_button=true
}
}
var mytimeout = $timeout($scope.onTimeout,1000);
}
$scope.checkCorrectness = function(){
$scope.ok=true
$scope.enterTextView=false
$scope.previewView=true
$scope.promptAction=''
$scope.promptLevel=''
/*dummy check*/
if($scope.ok){
$scope.level= $scope.level + 1
$scope.promptLevel='Level: ' + $scope.level
}
}
})
Plunkr::次のように
私のコントローラがあるhttp://plnkr.co/edit/eYKQPM?p=preview