TerrificJS & modularization / js dependency management

105 views
Skip to first unread message

Igor Minar

unread,
Jul 31, 2011, 4:23:14 AM7/31/11
to ang...@googlegroups.com

These guys are going with the super-hero theme as well. :-) 

I looked at some of their examples, but it looks like their super-hero will die from over-typing before he has a chance to save the world. http://jsfiddle.net/brunschgi/uzjSM/

One nice thing they did figure out was js dependency management (load a js file (e.g. jquery plugin) only when it is needed. We could do the same by extending the $route service as I intended anyway.

Something like:

$route.when('/foo', { template: 'foo.html', controller: Foo, requires: ['foo.js'] }

Internally, we would keep track of what was already loaded, and we would load only js files that weren't evaluated yet.

It's not a feature that is high on my list, but wanted to throw it out there in case people have other thoughts or suggestions.

/i

Vojta Jina

unread,
Jul 31, 2011, 5:21:10 AM7/31/11
to ang...@googlegroups.com
I would extract this "lazy loading" mechanism into separate service, which could be called onRouteChange. Then you can use the service even without $route...
But that's just quick idea - maybe we actually don't need that...
V.

Igor Minar

unread,
Jul 31, 2011, 5:36:55 AM7/31/11
to ang...@googlegroups.com
onRouteChange is too late, similarly to the template, these js dependencies must be loaded before the controller is instantiated.

/i

--
You received this message because you are subscribed to the Google Groups "angular" group.
To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/PzrmLmJE8HgJ.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/angular?hl=en.

Vojta Jina

unread,
Jul 31, 2011, 3:40:30 PM7/31/11
to ang...@googlegroups.com
The controller is instantiated after onChange callbacks, but you are right - this is bit more complicated, as we need to wait for the <script> to be downloaded and evaluated...

V.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages