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

sorenhoyer avatar Jul 08 '14 18:07 sorenhoyer

+1

csbenjamin avatar May 23 '15 03:05 csbenjamin

This is out of scope for AngularJS 1.x. Generally, the module loading went into the direction of ES6 modules + transpiling.

Narretz avatar Sep 27 '17 19:09 Narretz