I want to put a link in the scale label for each section of the timeline, something like this:
scheduler.addEventListener('onTemplatesReady', onTemplatesReady);
function onTemplatesReady() {
scheduler.templates.timeline_scale_label = function(key, job) {
return '<a ui-sref="jobsView({ jobId: ' + job.id + ' })">#' + job.id + '</a>';
}
}
Where can I hook into this and run the angular $compile function?
Can you please point to some usage of $compile method ?
As far as I can see it is used only inside of Angular’s directives and can’t be used outside of them.
I have to admit I don’t fully understand $compile and thought it was more about passing some raw html and it would compile any directives within e.g. system (ng-repeat, ng-click etc…) or custom.
I have found another way which isn’t too hacky which is to call a method on my view controller that the scheduler sits within from outside of angular.
This is done by using the following code in case anyone is interested:
scheduler.addEventListener('onTemplatesReady', onTemplatesReady);
function onTemplatesReady() {
scheduler.templates.timeline_scale_label = function(key, job) {
return '<a href="#" onclick="angular.element('#scheduler').controller().viewJob('+job.id+')">View job</a>';
}
}
This can also be achieved by doing .scope() instead of .controller(), depending on how your angular app is setup.