What is the AngularJs compile equivalent in Angular 4?

143 views
Skip to first unread message

Oram Herstein

unread,
May 29, 2017, 5:46:23 AM5/29/17
to Angular and AngularJS discussion
Hello all,

We have an AngularJS application that injects components (directives) from pure JS and compiles them on the fly.

We want to gradually upgrade our application to Angular 4 and started creating and a hybrid application.
We need to use a similar mechanism to compile the new Angular 4 components that are injected from pure JS.

This is our currnet AngularJs service that handles the event of adding a new directive:

        private directiveAdded(e: CustomEvent) {
            service.getScope(id).then((scope) => {
                this.$compile(e.detail.element)(scope);
            });
        }


What is the equivalent way to do this in Angular 4?


Thanks for your help!

Sander Elias

unread,
May 29, 2017, 6:01:14 AM5/29/17
to Angular and AngularJS discussion
Hi Oram,

Currently, there is none. You can grab a hold off the JIT compiler, and do something with that, but that's not advisable. The most important reason, the JIT will go away in an (as near as possible) future. 
If you need something right now, there is not a nice solution, without hacking into Angular's internals. However, there is work being done, so dynamic templating will be possible. No timeframe, but probably way before the JIT is killed.

Regards
Sander
Reply all
Reply to author
Forward
0 new messages