javascript - Migrate to angular 2 -
i got legacy application written in angular 1 needs fixed.
i'm required write unit tests in order modifications app, questions are:
- is there framework can use write unit tests works in angular 1 , 2 without having modify them (or not much).
- how migrate thing? without having work, administration says should kept on angular 1, find angular 1 not angular 2 (probably because 2 reminds me of react more, , i'm react developer). thing every single page has module, controller , view (yes every single page), there no reusable components whatsoever, uses history api routing (in tangled way), if how change page page use angular 2 instead of 1?
eg. module
angular.module('catmodule') .config(function ($stateprovider) { $stateprovider .state('cats', { url: '/cats', templateurl: 'cats/cats.html', controller: 'catsctrl', authenticate: true }); });
controller:
angular.module('catmodule') .controller('catsctrl', function ($scope, $http, $firebaseobject) { $scope.catnumber = 10; //main spagetthi here... d: });
view:
<div>we got {{catnumber}} cats</div>
i need rough ideas, no need specific; have figure out things myself later anyway.
there's no such thing universal unit tests, need write different ones, doesn't mean can't copy or re-use of logic. best thing do, following official migration guide. can have 2 different versions working alongside. hardest part setting webpack , tooling, if not used that.
my advice? don't try fix isn't broken. angular 1 being used since 2009, lot has changed since then, it's still framework. if admnistration not willing move angular 2 , don't have support, keep doing angular 1.
because migration going stumble upon lot of difficulties, have learn angular 2, webpack, typescript , although go angular without typescript, won't find as documentation. have make 2 frameworks work alongside , re write unit tests. think twice before jumping migration.
Comments
Post a Comment