Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I would say that all of your points can be easly achived, at least without any modifications to Angular.</p> <blockquote> <ul> <li>being able to split controllers, directives, filters, etc. in their own files;</li> </ul> </blockquote> <p>this can be of course done with basic Angular, as you can include as many script tags with controllers/services as you want. Of course it's not scalable at all, so the best option would be using AMD modules, like RequireJS. This is one of the seeds that have this kind of configuration: <a href="https://github.com/elsom25/angular-requirejs-html5boilerplate-seed">https://github.com/elsom25/angular-requirejs-html5boilerplate-seed</a></p> <blockquote> <ul> <li>being able to load these files on demand rather than making the browser load everything;</li> </ul> </blockquote> <p>As <em>pkozlowski</em> suggested in the comments, there is already and entry with some description of the problem, you will see that I was also working to solve this, and actually had some results. <a href="https://github.com/matys84pl/angularjs-requirejs-lazy-controllers/blob/master/app/js/utils/lazy-directives.js">I have a working example of loading controllers, templates and directives on demand using RequireJS</a> and the <em>resolve</em> param of route configuration. </p> <blockquote> <ul> <li>being able to have common, cross-project components (e.g. common directives, filters or services)</li> </ul> </blockquote> <p>Having the previous points resolved it could be easily achived using RequireJs modules.</p> <hr> <p>I've been wondering whether starting an agularjs-lazy-seed project would be a good idea? Is there any demand for that? We could even take it further and move the routes configurations outside 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:</p> <pre><code>{ "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 } .... } } </code></pre> <p>This way you could:</p> <ul> <li>develop the views in separation and the build the application based on this json bootstrap</li> <li>have some common directives and components</li> <li>when bootstrap after the login you could filter the views that user is allowed to see</li> <li>everything inside the ngView would be loaded on demand</li> </ul> <p>Of course your application should then be really big so that doing all of this additional work would made sense ;)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload