【发布时间】:2014-06-09 13:36:41
【问题描述】:
<pre lang="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()">
这是 js 角码
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
}
]
})
我有一些问题 我想在测验对象服务时将问题添加到测验中如何添加我正在做的事情 这个
$scope.addQuiz= function($scope){
crudService.quiz.push({
Quiz: $scope.Question,
type: $scope.type,
answer: $scope.ans
})
}
但显示错误 TypeError:无法读取未定义的属性“问题” 如何推入服务的对象(测验)。 ?? 如何推入作为 Quiz 对象中另一个对象的选项。 ?? 另外我想允许用户添加答案类型 类型是 1:真\假(复选框) 2:多个答案(复选框) 3. 单一答案(单选) 这该怎么做 ??虽然我在测验中添加了一个选项,但不知道如何执行此操作并创建其布局??
【问题讨论】:
-
你可以为它制作一个小提琴吗?
标签: javascript angularjs html twitter-bootstrap css