angular-tree-control
angular-tree-control copied to clipboard
templateUrl example doesn't work
I copied the template from the demo, but didn't manage it to work.
The template seems to only be loaded if already on cache, and when loaded I got the error
Error: [$parse:syntax] Syntax Error: Token '{' is not a valid identifier at column 6 of the expression [node.{{options.nodeChildren}} | filter:filterExpression:filterComparator {{options.orderBy}}] starting at [{{options.nodeChildren}} | filter:filterExpression:filterComparator {{options.orderBy}}].
Is the example outdated? Any clue on how to make it work?
can you share your full example?
Are you using instance template or global template?
The example http://wix.github.io/angular-tree-control/#externalTemplate works and is current.
I'm using an instance template. I just noticed this directive depends on angular ~1.2.7. I'm using angular 1.4.4, so this might be the problem.
I put the template in script tag and it worked.
<script type="text/ng-template" id="permissionTree.html">
...
</script>
And I saw the source code get the template directly from $templateCache
Just verified it is working with angular 1.3.18. Can you share how you are using the feature?
On Mon, Nov 9, 2015 at 9:02 AM, Jason [email protected] wrote:
I'm using 1.3.18 and the templateUrl not working too
— Reply to this email directly or view it on GitHub https://github.com/wix/angular-tree-control/issues/167#issuecomment-154971840 .
Seeing this behavior as well. The issue is that $templateCache.get(templateUrl) will only return the template if its already cached. Hence, if you embed the template in JavaScript it will be pre-cached and work as expected.
As a workaround, when you bootstrap your app on load, you can pre-cache the template manually if it isn't already cached (in case you compile the templates for a production build).
if (!$templateCache.get('app/custom-template.html')) {
$templateCache.put('app/custom-template.html', 'app/custom-template.html');
}