Title.
SO I have a Job List array that displays as a list in HTML.I can add jobs through the page. I am trying to persist data with a database so I am trying to retrieve it right now.
So here's my getJobs from database method in my main controller. I put it in my main method because it's a pretty simple app.
Anyways, I debug it and I see that response does get the information from the database. It returns an array from my collections. It only has one object so far and its attribute name is "MyName". I see it says response.data[0].jobs would be the array, but I tried to set this.jobs to that and it didn't work. It says "can't set jobs to undefined". It adds something to my array, but it doesn't show anything.
So I am asking. How do I specifically link the array and objects in it with its attributes from the database to my local array in the application. Let me know if you need clarification and thanks a lot for the help. Much, much appreciated. Thanks!
//function using $http to get data from database
this.getJobs = function() {
$http.get("https://api.mongolab.com/api/1/databases/joblistdatabase/collections/jobs",
{params: {apiKey:"****************"}
}).then(function(response){
alert(response.data);
this.jobs = response.data;
},(function() {
alert("error");
}));
};