Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

templateUrl example doesn't work #167

Open
dcardosods opened this issue Oct 16, 2015 · 5 comments · May be fixed by #251
Open

templateUrl example doesn't work #167

dcardosods opened this issue Oct 16, 2015 · 5 comments · May be fixed by #251

Comments

@dcardosods
Copy link

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?

@yoavaa
Copy link
Contributor

yoavaa commented Oct 18, 2015

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.

@dcardosods
Copy link
Author

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.

@savokiss
Copy link

savokiss commented Nov 9, 2015

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

@yoavaa
Copy link
Contributor

yoavaa commented Nov 9, 2015

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 notifications@github.com wrote:

I'm using 1.3.18 and the templateUrl not working too


Reply to this email directly or view it on GitHub
#167 (comment)
.

@phrough
Copy link

phrough commented Jan 10, 2017

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');
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants