Problème Angularjs && Laravel
hi,
I am trying to make a part of a quiz app ( angular js frontend and laravel backend ), I'm stuck in to add a question, the treatment is as follows:
I have to choose the type of question and the number of options, and I click the next button, I redirect to a page containing the category and level of the quiz , question and options as the number of options already chosen
here is the html part of AngularJS:
ng-repeat="i in range(Data.nop)
Option {{i}}
input type="radio" name="score" value="{{i-1}}" ng-model="score" ng-checked="i==1"/ Select Correct Option
textarea ng-model="options" class="form-control" /textarea
the controller AngularJS:
quizapp.controller('QuestionController',function($scope,$http,$location,Data) { $scope.Data = Data; $scope.options=[];
//recuperation categories var resultat=$http.get('http://localhost/quiz/public/ListeCategories') resultat.success(function(categories, status, headers, config) {
$scope.categories = categories;
}); //recuperation niveaux var resultat=$http.get('http://localhost/quiz/public/ListeNiveaux') resultat.success(function(niveaux, status, headers, config) {
$scope.niveaux = niveaux;
});
$scope.redirect=function(){
$location.path("/new_question_1");
};
$scope.range = function(nop){
var input = []; nop = parseInt(nop); for (var i = 0; i < nop; i++) { input.push(i+1) }
return input; }
$scope.save = function() { console.log($scope.Data); var question = { "cid":$scope.cid, "nid":$scope.nid, "type_question" : $scope.Data.type_question, "question":$scope.question, "description":$scope.description };
var res = $http.post('http://localhost/quiz/public/addQuestion',question);
res.success(function(data, status, headers, config) {
$scope.data = data;
console.log($scope.data);
angular.foreach($scope.options,function(score,options){ // score =key, options=val if($scope.score==score){ $scope.score=1;// }else{ $scope.score=0; }
var option ={
"q_option":options, "qid":$scope.data.qid "score":score }; var resultat = $http.post('http://localhost/quiz/public/addOption',option); resultat.success(function(response, status, headers, config) { $scope.response = response
console.log($scope.response);
});
}) }); };});
quizapp.factory('Data', function(){ return { type_question: '' , nop:'' }; });
the problem there is not an error response and also no record in the data base
Please or to participate in this conversation.