angular.js icon indicating copy to clipboard operation
angular.js copied to clipboard

[feature request] [angular 1.3] Out of the Box Support for AMD

Open NathanielAJohnson opened this issue 12 years ago • 63 comments

Angular comes with a robust module framework that allows for easily looking up angular entities. It makes adding AMD loader support look strange and creates redundant requirement lists. From https://github.com/tnajdek/angular-requirejs-seed/blob/master/app/js/controllers.js

define(['angular', 'services'], function (angular) {
    return angular.module('myApp.controllers', ['myApp.services'])
            .controller('MyCtrl1', ['$scope', 'version', function ($scope, version) {
                    $scope.scopedAppVersion = version;
            }])
...

It would be preferable to be able to wrap the require.js define line into the angular.module line since the angular.module() is more concise but provides all the information that an AMD loader would require.

I would write an additional set of AMD methods that mimic the module so that the previous piece of code might look like this:

angular.amd.module('myApp.controllers', ['myApp.services'])
            .controller('MyCtrl1', ['$scope', 'version', function ($scope, version) {
                    $scope.scopedAppVersion = version;
            }])
....

Further reductions are probably possible but that would be a nice beginning.

UPDATE I have detailed my ideas on what I see as the problem and a potential solution. Please, comment on either page and I will update the proposal to fufill as a many expectations as possible.

NathanielAJohnson avatar Dec 14 '13 20:12 NathanielAJohnson

+1

ilplotkin avatar Dec 24 '13 07:12 ilplotkin

+1

yuriyp avatar Dec 24 '13 10:12 yuriyp

+1

ronaldronson avatar Dec 24 '13 15:12 ronaldronson

+1

shustariov-andrey avatar Dec 24 '13 18:12 shustariov-andrey

Something like this project? http://marcoslin.github.io/angularAMD/#/home It would be great to see something like that natively in Angular...

dgkimpton avatar Dec 25 '13 17:12 dgkimpton

+1

deepak-nulu avatar Dec 26 '13 00:12 deepak-nulu

+1

ubenzer avatar Dec 27 '13 11:12 ubenzer

+1

altundal avatar Dec 27 '13 12:12 altundal

+1

reyramos avatar Dec 27 '13 15:12 reyramos

I have written a far more detailed proposal that can be found at https://github.com/NathanielAJohnson/angularAMD

Please feel free to comment, suggest, complain. It is a starting point for a community discussion.

NathanielAJohnson avatar Dec 28 '13 04:12 NathanielAJohnson

+1

jkerkhofs avatar Dec 28 '13 09:12 jkerkhofs

+1

saydogan avatar Dec 28 '13 12:12 saydogan

+1

wro avatar Dec 28 '13 12:12 wro

+1

alex6o avatar Dec 28 '13 12:12 alex6o

+1

sudhakar avatar Dec 30 '13 07:12 sudhakar

If you do such thing please make it so that "AMD" (witch version of it, by the way ?) is not forced upon us in any way, I tend to think (And I might not be alone in this) that it is an undebogable and unreliable mess at the moment with no good tooling support nor any defined / well though out / battle tested standard. Right now advocate of AMD can already use it with angular and there are at least a dozen github repos devoted to precisely that. But the approachability and capability to fall back on direct loading is a great plus for learning and sometime debugging AJS applications and it would greatly diminish the framework to loose that.

PS : and I completely separate modularity ( a good thing) from deferred loading (a much more dubious thing in many applications)

Annakan avatar Dec 31 '13 22:12 Annakan

+1

michaelhart avatar Jan 02 '14 15:01 michaelhart

+1

klebba avatar Jan 05 '14 03:01 klebba

+1

aqzhyi avatar Jan 07 '14 14:01 aqzhyi

+1

bradleytrager avatar Jan 07 '14 19:01 bradleytrager