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

The move to template-url disallows the use of scoped values #11

Open
icfantv opened this issue Jan 24, 2017 · 6 comments
Open

The move to template-url disallows the use of scoped values #11

icfantv opened this issue Jan 24, 2017 · 6 comments

Comments

@icfantv
Copy link

icfantv commented Jan 24, 2017

One of the older versions of your library allowed for the specification of a user-defined template via an options.templateUrl property. The switch to a templateUrl function now no longer allows the user to use a scoped variable as, per the angular documentation, scoped values are not accessible because the template function is executed before the scope is even initialized.

This means that one cannot do template-url="{{ vm.template }}". I don't have a great solution here and it's clear that angular is not going to fix this issue.

You can see the issue here along with an attempted fix using injected $element, $attrs service values. You can ignore the parsing error and just look at the template value.

@icfantv
Copy link
Author

icfantv commented Jan 24, 2017

There's an ugly way (read: hack) of using $templateCache to resolve this issue when using webpack's require and a template loader:

.run($templateCache => $templateCache.put('some-string', $templateCache.get(require('path/to/template.html')));

And then use some-string as the value of your template-url attribute.

It's ugly because you have the same entry in your cache twice.

@vincentjames501
Copy link
Owner

Nice. To be honest I haven't done much testing with loading another template. Do you have any suggestions?

@icfantv
Copy link
Author

icfantv commented Jan 24, 2017

I'm in the process of updating our template to account for all the changes from 0.0.6 (where there was a bug we just found about the hourly regex check was incorrectly matching a daily cron expression). I can link this issue in to my PR in our project when I have it done so you can see what we wound up doing.

@icfantv
Copy link
Author

icfantv commented Jan 25, 2017

@vincentjames501 here's the PR for our project utilizing a custom template.

@vincentjames501
Copy link
Owner

@icfantv , would you be willing to update the README with a PR and document how you did it?

@icfantv
Copy link
Author

icfantv commented Feb 1, 2017

@vincentjames501 yea, but it's not straightforward. i had to look at your demo and the classes themselves to see what was exposed to put into a custom template. if you were to document your classes that might make it a lot easier.

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

No branches or pull requests

2 participants