I am new in angularjs and I cant figure out some stuff please help I want to rep
ID: 3690404 • Letter: I
Question
I am new in angularjs and I cant figure out some stuff please help
I want to replace this line of code :
<div class="intro {{ (activeQuestion > -1) ? 'inactive' : 'active' }}">
inestesd of using this (if else) in index.html I want to use it in app.js
Also, is there any way to replace isSelected($parent.$index , $index) in the following code:
I do not want use ($parent.$index , $index)
<p class="txt">{{myQuestion.question}}</p>
<p class="ans"
ng-class="{
image:Answer.image,
selected:isSelected($parent.$index , $index)}
here is app.js:
$scope.isSelected = function(qIndex, aIndex){
return $scope.myQuestions[qIndex].selectedAnswer === aIndex;
}
Explanation / Answer
Write like this in app.js file
$scope.isSelected = function(qIndex, aIndex){
var index = $scope.myQuestions.indexof(myQuestion);
$scope.selected.index = $scope.myQuestions[index];
return $scope.myQuestions.index;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.