Angular2 with angular.sfx.dev.js

182 views
Skip to first unread message

Brijesh Kachalia

unread,
Jan 26, 2017, 5:16:34 PM1/26/17
to Angular and AngularJS discussion
I want to use single Angular2 Javascript file in my project. I found that angular.sfx.dev.js does the work, however most of the example are on Typescript & I find difficulty in hooking LifeCycle events & calling angular2 function from outside.

Please check https://jsfiddle.net/yppoa14c/1/ & let me know what is the correct way to receive alert message from fiddle at different lifecycle event. I also want to invoke setMyTxt function from outside but I am not sure how to execute it. If some one can help me by updating the fiddle that would be great.



Brijesh Kachalia

unread,
Jan 26, 2017, 5:16:51 PM1/26/17
to Angular and AngularJS discussion
I want to use single javascript file for Angular2 in my project & I found that Angular2 provides angular.sfx.dev.js. I found one jsfiddle https://jsfiddle.net/langdonx/n5pjgev6/ which demonstrate use of it. I found that there are lot of example in typescript but very less using angular.sfx.dev.js.

Examples for Lifecycle, & NgZone (call angular2 function from outside using old js/jquery) are not found in detail. I tried ngOnInit as well OnInit to see if either of it works (similarly ngOnChange & OnChange) in above jsfiddle but unable to print on console log on each event. 

If some point me to good article that uses angular.sfx.dev.js  or update above jsfiddle to let me know how lifecycle & calling angular function from outside using plain old javascript it would be of great help.

Sander Elias

unread,
Jan 27, 2017, 1:46:17 AM1/27/17
to Angular and AngularJS discussion
Hi Brijesh,

Your sample is using an ancient version of Angular. I'm not sure those life-cycle events were in that version anyway. I'm sorry to say, but as far as I know, there is no 'single file' angular version anymore. Here is a plunk showcasing the minimal setup you need. Of coarse, you can manually bundle all those files, and host them on your own. But I thnk that's unwise. 

Regards
Sander

Brijesh Kachalia

unread,
Jan 27, 2017, 11:17:47 AM1/27/17
to Angular and AngularJS discussion
Hi Sander,

Thanks for the reply.

What is the best way that you think to keep track of release. I am asking  this question (possible weird) because I am confuse as on stackoverflow (url given below) they are suggesting angular2 is maintaing self containing file too!! 

I am not interested in maintaining & converting typescript files into javascript. what is the best way that I get all the related angular2 source file that is enough to code in js or emascript, so next time I can just do npm or refer to website for new releases.

Also can you share fiddle with angular2 lifecycle (any one event)  & how to call angular function from outside as my project is pure js/jquery & angular2 is just added feature to it so I need to some how call angular2 function from outside



Brijesh

Sander Elias

unread,
Jan 27, 2017, 12:11:16 PM1/27/17
to Angular and AngularJS discussion
Hi Brijesh,

I linked a plunk that has all the current JS files.  I forked it from the official JS documentation. There is no need to touch typescript at all if you use those. However, it is not a single file, if you want that, you need to bundle those resources yourself.

Regards
Sander

Brijesh Kachalia

unread,
Jan 27, 2017, 4:02:07 PM1/27/17
to Angular and AngularJS discussion
Hi Sanders,

Your plunker is working beautifully.. Thank You.

Regards,
Brijesh

On Thursday, January 26, 2017 at 5:16:34 PM UTC-5, Brijesh Kachalia wrote:
Reply all
Reply to author
Forward
0 new messages