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

That would be great. +1

Thomasdezeeuw avatar Dec 14 '13 22:12 Thomasdezeeuw

+1

dennisoehme avatar Dec 15 '13 10:12 dennisoehme

+1

slatkovic avatar Dec 20 '13 01:12 slatkovic

+1

CWSpear avatar Dec 20 '13 16:12 CWSpear

+1

cheahkhing avatar Dec 20 '13 16:12 cheahkhing

+1

bilboon avatar Dec 20 '13 16:12 bilboon

+1

mjelicic avatar Dec 20 '13 17:12 mjelicic

+1 Excellent feature.

ghost avatar Dec 20 '13 18:12 ghost

+1

mauricedb avatar Dec 20 '13 18:12 mauricedb

+1

rnikitin avatar Dec 20 '13 21:12 rnikitin

+1

tobio avatar Dec 20 '13 22:12 tobio

+1

themihai avatar Dec 21 '13 05:12 themihai

+1

a-tarasyuk avatar Dec 21 '13 16:12 a-tarasyuk

+1

mattreyuk avatar Dec 21 '13 22:12 mattreyuk

+1, it would be awesome!

sukei avatar Dec 23 '13 11:12 sukei

+1

dehru avatar Dec 23 '13 16:12 dehru

+1

marfarma avatar Dec 23 '13 17:12 marfarma

+1 I would like to see the ability to load controllers on demand as well in conjuncture with Routing and ngView or when a template is pulled in that references a controller.

runxc1 avatar Dec 23 '13 23:12 runxc1

+1001!

hackdan avatar Dec 24 '13 00:12 hackdan

I am working on a more complete spec. I want to lay out a solution that incorporates the AMD loader without breaking the framework as it exists. This means that I will probably suggest a separate angular module that is defined in much the same way as require.js is but doesn't break the non-amd angular structure and also removes the redundant require/define statements.

I will try to have a full spec by December 26th and make it available via blogger. If it gets enough traction, and the angular team is OK with it, I will offer a first pass of the implementation by mid-January.

What I will really need is input form those of you that want to see this as much as I do.

On Mon, Dec 23, 2013 at 5:30 PM, runxc1(Bret Ferrier) < [email protected]> wrote:

+1 I would like to see the ability to load controllers on demand as well in conjuncture with Routing and ngView or when a template is pulled in that references a controller.

— Reply to this email directly or view it on GitHubhttps://github.com/angular/angular.js/issues/5410#issuecomment-31150078 .

NathanielAJohnson avatar Dec 24 '13 00:12 NathanielAJohnson