Oh, that's because your jobs have not been fetched yet. When ou call getJobStatus() on jobService, it merely fires the request. It does not complete the request.
So your code is executed like this (from ngOnInit forward):
- this.getjobsStatus() // on jobsComponent
- getjobsStatus calls jobsService.getJobStatus()
- that, in turn, _prepares_ the http request and stuff. Doesn't send anything yet (or it even might). It does not, however receive an instant reply, and instead it returns.
- now your console.log("jobs data is ",
this.jobs) is called, printing nothing.
Now you wonder what's going on, but later...
- then that actual http request gets fired. (by the browser, outside of JS VM)
- then the server does its mojo and returns a json
- then your function is returned.
If you want to actually see the results once they're back, you should edit your JobsComponent.getjobsStatus like this:
this._jobService.getJobStatus().subscribe(
response => {