i have this html
<ul>
<li data-ng-repeat="q in QuizObj">
<fieldset><legend>All Quizes </legend>
<h1>{{q.Quiz }}</h1>
<h3>options</h3>
<h3>answer</h3>
<input type="radio" />{{q.options[1]}}
<input type="radio" />{{q.options[2]}}
<input type="radio" />{{q.options[3]}}
<input type="radio" />{{q.options[4]}}
<h4>Answer</h4>
<input type="radio" />{{q.answer}}
</fieldset>
</li>
</ul>
<input type="text" ng-model="ans">
<input type="text" ng-model="Question" >
<input type="text" ng-model="type">
<input type="button" data-ng-click="addQuiz()">
and this is js angular code
angular.module('quizApp',[])
.controller('mainCtrl',function($scope,crudService){
$scope.name="this";
alert(JSON.stringify(crudService.quiz));
$scope.QuizObj= crudService.quiz;
})
.service('crudService',function(){
this.quiz=[
{
Quiz: "what is the C#",
options: { 1: 'P-lang',
2:'h-lang',
3: 'A-lang',
4: 'nothing'
},
type: 'radio',
answer: 1
},
{
Quiz: "what is the J#",
options: { 1: 'P-lang',
2:'h-lang',
3: 'A-lang',
4: 'nothing'
},
type: 'radio',
answer: 1
},
{
Quiz: "what is the VB",
options: { 1: 'PL',
2:'hL',
3: 'AL',
4: 'nothing'
},
type: 'radio',
answer: 1
}
]
})
i have a some problem
i want to add question into quiz while quiz object is in service how to add this i am doing
this
$scope.addQuiz= function($scope){
crudService.quiz.push({
Quiz: $scope.Question,
type: $scope.type,
answer: $scope.ans
})
}
but showing me an error
TypeError: Cannot read property 'Question' of undefined
how to push in services's object (quiz). ??
how to push in option which is another object in Quiz object. ??
plus i want to allow user to add type of answer
types are
1: true\false (checkbox)
2: Mulitiple answer (checkbox)
3. single answer (radio)
how to do this ?? although i have added a opition in quiz but don't know how to do this and create its layout??