The combo in the topic is giving me a hard time, I'm sure it's a simple mistake somewhere.
Controller:
class JobCtrl {
job: Object;
public $inject = ['$log', '$resource', 'ApiDataEndpoint', '$stateParams'];
constructor(public $log, public $resource, public ApiDataEndpoint, public $stateParams ) {
var JobRes = $resource(ApiDataEndpoint.url+'job/:id', {});
var jobCall = JobRes.get({ id: $stateParams.id},function(){
this.job = jobCall;
})
}
}
The route is defined like this:
.state('app.job', {
url: '/jobs/:id',
views: {
'menuContent': {
templateUrl: 'templates/job.html',
controller: 'JobCtrl',
controllerAs: 'vm'
}
}
})
in my view I got this:
<p>
Name: {{vm.job.Name}}
</p>
But the view never updates when the callback returns. I'm guessing it's either an async problem or a scope problem. Fetching the resource works perfect, the view just never updates. It's seems as I can't set this job from within the callback. What am I missing here?
{{vm.job.Name}}
in the view? If so, your code isn't valid and there should be an error. Or do you just seeName:
? – Goldenowner Jan 7 at 12:49this.job = JobRes.get({id: $stateParams.id});
should be enough – Gustav Jan 7 at 14:01