angular-cron-gen
angular-cron-gen copied to clipboard
The move to template-url disallows the use of scoped values
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.
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.
Nice. To be honest I haven't done much testing with loading another template. Do you have any suggestions?
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.
@vincentjames501 here's the PR for our project utilizing a custom template.
@icfantv , would you be willing to update the README with a PR and document how you did it?
@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.