Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello guys,
I was trying to use angularjs in qlik sense extension but realise that without a template, angularjs cannot run.
So I include the template: templateContent but instead, my paint function does not run.
Do you guys have any idea? Below is an extract of the extension:
Do note that templateContent and the other variables in the extract are properly loaded in the define function.
return {
type: 'visualization',
definition: properties,
initialProperties: initialproperties,
snapshot: {
canTakeSnapshot: true
},
template: templateContent,
paint: function($element, layout) {
alert('a'); // this is never called but if I remove "template: templateContent", it will
}
};
You define that in your controller by listening for re-size events depending on what you want do.
Think of it as the controller will replace your paint function. There are great angular resources on the web, I would recommend you read up on it if you decide to go the angular route instead of good ol' JavaScript.
Kind Regards
Alexander Karlsson
Ye so if you have a template your 'rendering' should happen in the template.
If you decide to go the angular route then you probably also want a controller assigned to the template as you opted out of the paint function.
The controller will be in charge of manipulating the data that is on scope which you then render in your template.
The documentation has a good example on it here https://help.qlik.com/sense/en-us/developer/index.html#../Subsystems/Workbench/Content/CodeExamples/...
The extension layout will be on scope and accessible from your template by default so you can do something like
<div ng-repeat="row in layout.qHyperCube.qDataPages[0].qMatrix">
I hope that makes things a little bit clearer
Hmm ok, that's good information to know that paint function will not be utilised if going down the angular route. However if the paint function cannot be used, how can I get the extension to do something whenever the visualization is resized?
You define that in your controller by listening for re-size events depending on what you want do.
Think of it as the controller will replace your paint function. There are great angular resources on the web, I would recommend you read up on it if you decide to go the angular route instead of good ol' JavaScript.
Kind Regards
Alexander Karlsson
That's great insight Alexander! Ok, I got a better idea on how angular works in qlik sense extension, totally appreciate your inputs.