app.controller("jobseekerCtrl", function($scope, $http) {

	$scope.init = function() {
		$scope.job = {};
		$scope.job.date = $scope.getDateString(new Date());
		$scope.joblist = [];

		$http({
			url: "http://127.0.0.1:8000/jobs",
			method: "GET"})
		.then(function successCallback(response) {
			$scope.joblist = response.data;
		}, function errorCallback(response) {
			console.log(response.statusText);
		});
	};

	$scope.addJob = function() {
		var jobobj = $scope.getJobObject($scope.job);

		$http({
			url: "http://127.0.0.1:8000/jobs",
			method: "POST",
			data: $.param($scope.job),
			headers: { "Content-Type": "application/x-www-form-urlencoded"}})
		.then(function successCallback(response) {
			$scope.joblist.push(jobobj);
		}, function errorCallback(response) {
			console.log(response.statusText);
		});

		$scope.resetForm();

	};

	$scope.deleteJob = function(id, index) {
		$http({
			url: "http://127.0.0.1:8000/jobs/" + id,
			method: "DELETE",
			headers: { "Content-Type" : "application/x-www-form-urlencoded" } })
		.then(function(response) {
			$scope.joblist.splice(index, 1);
		}, function(response) {
			console.log(response.statusText);
		});

	};

	$scope.resetForm = function() {
		$scope.job = {};
		$scope.job.date = $scope.getDateString(new Date());
	};

	$scope.getDateString = function(date) {
		var dt = new Date(date);
		return (dt.getMonth()+1) + "/" + dt.getDate() + "/" + dt.getFullYear();
	};

	$scope.getJobObject = function(job) {
		return { date : job.date, title : job.title, company : job.company, location : job.location, via : job.via };
	};

});

@@ -446,57 +446,8 @@
 ) %7B%0A
-%09%09var jobobj = $scope.getJobObject($scope.job);%0A%0A
 %09%09$h
@@ -444,32 +444,32 @@
 n() %7B%0A%09%09$http(%7B%0A
+
 %09%09%09url: %22http://
@@ -680,14 +680,21 @@
 ush(
-jobobj
+response.data
 );%0A%09
@@ -798,17 +798,16 @@
 Form();%0A
-%0A
 %09%7D;%0A%0A%09$s
@@ -922,78 +922,8 @@
 ETE%22
-,%0A%09%09%09headers: %7B %22Content-Type%22 : %22application/x-www-form-urlencoded%22 %7D
  %7D)%0A
@@ -1241,16 +1241,16 @@
 (date);%0A
+
 %09%09return
@@ -1324,164 +1324,8 @@
 %7D;%0A%0A
-%09$scope.getJobObject = function(job) %7B%0A%09%09return %7B date : job.date, title : job.title, company : job.company, location : job.location, via : job.via %7D;%0A%09%7D;%0A%0A
 %7D);%0A

fix for issue #5 - being unable to delete newly added jobs