How to implement angular AMD in SystemJS?

I am currently using requirejs + AMD to load modules asynchronously, but since we are going to port our angular 1.x application to angular 2 and above, I don’t know if js system supports AMD function or not

If systemjs supports AMD, suggest how I can implement AMD routes (based on state) from systemjs in angular 1.5.

Routes.js

    $stateProvider.
        state('login', angularAMD.route({
            url: '/login',
            templateUrl: 'auth/login.tmp.html',
            controllerUrl: appPath + 'auth/login.ctrl.js',
        })).
        state('home', angularAMD.route({
            url: '/home',
            controllerUrl: appPath + 'home/home.ctrl.js',
            templateUrl: appPath + 'home/home.tmp.html',
        }))

In the above code example, how would I implement the same behavior that angularAmd.route do in systemjs?

I tried using the following code in the routes.js file (after searching on google)

define(['app', 'login.ctrl.js', 'home/home.ctrl.js'], function(app) { // do code here }

How SystemJS resolves AMD through define / require.

Please let me know if you need more information.

+4

Source: https://habr.com/ru/post/1693259/


All Articles