I would say that all of your points can be easily achieved, at least without any changes to Angular.
- the ability to separate controllers, directives, filters, etc. in your own files;
this can be done, of course, with the basic Angular, since you can add as many script tags with controllers / services as you want. Of course, it is not scalable at all, so the best option would be to use AMD modules such as RequireJS. This is one of the seeds that have this configuration: https://github.com/elsom25/angular-requirejs-html5boilerplate-seed
- the ability to download these files on demand, and not download all browsers;
As pkozlowski suggested in the comments, there is already an entry with some description of the problem, you will see that I also worked on this, and actually had some results. I have a working example of loading controllers, templates, and on-demand directives using RequireJS and the route configuration permission option.
- may have common, cross-project components (e.g., general directives, filters, or services).
If the previous points were allowed, they could be easily obtained using the RequireJs modules.
I was wondering if the idea of creating an agularjs-lazy-seed project would be a good idea? Is there any demand for this? We could even take it further and transfer the route configurations beyond the usual configuration, let's say you have a views.json file (ideally a service that responds with json) with the views you want to include in your application:
{ "views" : { .... "account" : { "path" : "/account" // route path "name" : "Account", // view name "partial" : "views/account/account.html", // partial file "controller" : "account/main" // RequireJS module "directives" : [ "directives/version", "directives/menu" ] // directives used in the view } .... } }
That way you could:
- Develop views in the partition section and build an application based on this json bootstrap
- have some common directives and components
- when loading after logging in, you can filter the views that the user can see
- everything inside ngView will load on demand
Of course, your application should be really big, so doing all this extra work would make sense;)
matys84pl Nov 23 '12 at 19:34 2012-11-23 19:34
source share