I am Working on this task from 2 days , i am trying to push unique id object into array but it is not working and css also not working for selection and deselection. Here my code below
HTML :
<li><a href="" ng-class="{'activeQuestion' :active}" ng-click="selectAnswer('{{ans.choiceID}}')"><choicecontentdesc></choicecontentdesc></a></li>
CSS:
#questionFullWidthPanel #questionRight nav li .activeQuestion {
//background: url(../img/ico/checked.png) !important;
background-repeat: no-repeat !important;
background-position: 90% center !important;
background-color: #ececec; !important;
//border-top: 1px solid #b9db92;
//border-bottom: 1px solid #b9db92;
color: #81be4a !important;
font-family: "proxima_nova_rgbold" !important
}
Directive:
scope.$parent.$parent.$parent.$parent.selected=[];
scope.selectAnswer = function () {
//alert(scope.id);
if (scope.ansSubmitted) {
return;
}
console.log("posssss",scope.$parent.$parent.$parent.$parent.selected.indexOf(scope.id));
scope.$parent.$parent.$parent.$parent.selectedObj = {
'selectedChoiceId' : scope.id,
'selectedChoiceDesc' : scope.text
};
console.log("obj",scope.$parent.$parent.$parent.$parent.selectedObj);
scope.active = scope.id === scope.$parent.$parent.$parent.$parent.selectedObj.selectedChoiceId;
var pos = scope.$parent.$parent.$parent.$parent.selected.indexOf(scope.id);
console.log("pos",pos);
if (pos == -1) {
scope.$parent.$parent.$parent.$parent.selected.push({
id: scope.$parent.$parent.$parent.$parent.selectedObj.selectedChoiceId,
text: scope.$parent.$parent.$parent.$parent.selectedObj.selectedChoiceDesc,
//datecolor:$scope.color
})
console.log("array1",scope.$parent.$parent.$parent.$parent.selected);
} else {
scope.$parent.$parent.$parent.$parent.selected.splice(pos, 1);
}
Does anyone know how to implement it??