Seeking assistance as I delve into learning angularjs. While I have figured out how to save one item to a database, my goal is to take it a step further and save multiple items. Unfortunately, my searches online have not yielded any results on how to accomplish this with angularjs. Is it even possible to achieve this in angularjs? To better illustrate my query, I have included the code on Plunker.
http://plnkr.co/edit/sF3mBOcDilhQDQKYqeE7?p=preview
script.js
var app = angular.module('multi', []);
app.controller('MainCtrl', function ($scope) {
$scope.students = [{
'firstname' : $scope.user_name,
'lastname' : $scope.lastname,
'bday':$scope.bday,
'bplace':$scope.bplace,
'sex':$scope.sex
}];
$scope.addNewStudent = function() {
var newItemNo = $scope.students.length+1;
$scope.students.push({'id':'student'+newItemNo});
};
$scope.removeStudent = function() {
var lastItem = $scope.students.length-1;
$scope.students.splice(lastItem);
};
$scope.save = function() {
$http.post('db.php?action=addStudent',
{
'firstname' : $scope.firstname,
'lastname' : $scope.lastname,
'bday':$scope.bday,
'bplace':$scope.bplace,
'sex':$scope.sex
});
};
});
After entering the information for each student, I aim to click the save button to store all students in my database. If this is indeed achievable, can you provide guidance on this matter? Thank you.