hmm: AngularJS 1.5 zu Angular 8 migrieren

Beitrag lesen

Hi Leute,

ich versuche gerade ein in Angular 1.5 geschriebenes UI nach AngularJS zu migrieren.

Im ersten Schritt soll man dafür alle AngularJS Controller in Komponenenten umwandeln. Kennt ihr eine gute Beschreibung die zeigt wie das geht? Mir liegen nur Beschreibungen vor die zeigen wie man .ts Controller umwandelt, meine Controller sind aber alle in JavaScript Dateien geschrieben. Beispiel:

(function() {
    'use strict';

    angular
        .module('gdbsuiApp')
        .controller('HomeController', HomeController);

    HomeController.$inject = ['$rootScope','$scope', 'Principal', 'Auth', '$state','$sessionStorage'];

    function HomeController ($rootScope,$scope, Principal, Auth, $state,$sessionStorage) {
        var vm = this;

        vm.account = null;
        vm.isAuthenticated = null;
        vm.login = login;
        $scope.$on('authenticationSuccess', function() {
            getAccount();
        });

        getAccount();

        function getAccount() {
            Principal.identity().then(function(account) {
                vm.account = account;
                vm.isAuthenticated = Principal.isAuthenticated;
            });
        }

        function open () {
            $state.go('home');
        }

        function login (event) {
            event.preventDefault();
            Auth.login({
                           username: vm.username,
                           password: vm.password,
                           rememberMe: false
                       }).then(function () {
                vm.authenticationError = false;

                $state.go('release');

                $rootScope.$broadcast('authenticationSuccess');

                // previousState was set in the authExpiredInterceptor before being redirected to login modal.
                // since login is succesful, go to stored previousState and clear previousState
                if ($sessionStorage.previousStateName) {
                    var previousStateName = $sessionStorage.previousStateName;
                    var previousStateParams = $sessionStorage.previousStateParams;
                    delete $sessionStorage.previousStateName;
                    delete $sessionStorage.previousStateParams;
                    $state.go(previousStateName, previousStateParams);
                }
            }).catch(function () {
                vm.authenticationError = true;
            });
        }
    }
})();