I came here from this GitHub 
issue: https://github.com/angular/angular.js/issues/10805#event-221306745

I believe that the proposed solutions are just superfluous patches to what 
the real problem is:
- Angular already comes with a module system, but it is not standard 
compliant, and it is just a sub set of the other module systems out there 
(Es6, Common.js, AMD)

I would like to get rid of Angular's module system in favor of more feature 
full Module systems.
I believe that Angular 2.0 brings new ideas to the table, you can check 
this Video by Vojta Jina: https://www.youtube.com/watch?v=_OGGsf1ZXMs

What are the chances to implement this into Angular 1.x? I believe that is 
not but totally feasible.

Here is the proposed syntax for Angular 2.0 Dependency Injection with Es6 
modules (based on the video by Votja):

Import {Grinder} from './grinder';
// Manually annotate the function
coffeeMaker.annotations = [
   new Inject(Grinder)];

function coffeeMaker(grinder) {...}
export coffeeMaker;



This of course transpiles into Common.js and AMD.
And this is how I imagine using it with Angular 1.x today (and Common.js)


var Grinder = require('./grinder');
// Manually annotate the function
coffeeMaker.$inject = [Grinder];// The below is necessary in my mind to make it 
easier to hook to the standard component definition
coffeemaker.$type = 'factory';

function coffeeMaker(grinder) {...}

module.exports.coffeeMaker = coffeeMaker;



And maybe basing on some interface like this we can hook up to Angular's DI.
I will try to make some experiments with this.
What do you guys think?

Thanks!
Fran



El jueves, 15 de enero de 2015, 12:51:13 (UTC-3), Marcus Nielsen escribió:
>
> I would expect var angular = require('angular') to work. And then module 
>> dependencies via var dependecies = [require('foo').name, 
>> require('bar').name].
>>
>
> Then only thing that is bothering me right now with browserify and angular 
> is the clash between DI and CommonJS.
>
> Personally I put my DDO inside my index.js and there set up my 
> angular-specific code and names. 
> // Inside a folder named mn-menu
>
> var moduleName = 'mnMenu'
> var controllerName = moduleName + 'Controller'
> var dependencies = []
> angular.module(moduleName, dependencies).directive(moduleName, function 
> (){
>   return {
>     template: require('./template.html'),
>     controller: controllerName
>   }
> })
>   .controller(controllerName, require('./controller'))
>
> If I do a folder for mn-footer, then I just copy that and replace the 
> folder-name and the variable moduleName to 'mnFooter'. Everything else 
> remains the same.
>
> That's how I use it right now. 
> Angular becomes the boilerplate code and my controller/factories become 
> normal functions with DI that are exported via CommonJS.
>
>>  
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to