Angular 1.3 meets Angular 2.0 - Michał Gołębiowski
Why Stack Overflow recommends it
Stack Overflow users link it when asking or answering how to prepare AngularJS 1.x code for Angular 2, especially converting services, factories and controllers to ES6 or TypeScript classes.
Recommended by 3 people across 2 different months, 2015 to 2015.
What it is
A 2015 ng-conf talk by Michał Gołębiowski on how to write Angular 1.3 code that will be easier to move to Angular 2.0. It shows patterns such as writing services and controllers as ES6 classes and preparing for the coming framework changes.
What people said
Recommends Tim Kindberg · 2015-03 · Stack Overflow · on “How to convert an angular $resource factory (not service) to ES6”
I'd like to start preparing for Angular 2 by converting existing code over to ES6 (as recommended in this video [this video] ). However, I'm immediately stumped, or perhaps unsure about how to proceed. In the video they show a conversion of a service. In my code I'm trying to convert a factory, which is similar but actually quite different when trying to convert to ES6. The service easily follows the class instantiation method, but factories need to return the injected object. My code started like this: melange.factory('SomeService', ['$resource', function ($resource) { var someResource = $resource('/api/endpoint'); someResource.customQuery = function() { // ... do some custom stuff }; return som
Recommends Chandermani · 2015-03 · Stack Overflow · on “is it safe to write a new application in angularjs 1.2?”
Migration from Angular 1.2 to 1.3 is far more easier as compared to moving to Angular 2.0 There is even a migration guide [LINK] to migrate from 1.2 to 1.3. So migrating would be possible to 1.3 or 1.4 or 1.x. There is a bit of paradigm shift when it comes to Angular 2.0. The migration path is still not clear and we even don't know whether one is possible. Update : This video from ngconf 2015 [this video] , gives some useful insight into how build today with 1.3, that makes transition easy.
Recommends Chic · 2015-04 · Stack Overflow · on “Angular 2.0: Migration path from Angular 1.x”
At the 2015 ng-Conf, the Angular team discussed initial concepts for this. Important things to note: You will be able to mix and match Angular 1 and Angular 2 modules so that you can incrementally move your app to Angular 2. Angular 2 will be written using TypeScript/ES7 so it may help you to use those languages and transpile them to ES5 for your current app. While you can use ES5 in Angular 2, there are things like class structures and annotations/decorators that may make working with Angular 2 easier. Migration instructions will be publish after Google has gone through the work of migrating one of it's internal applications. Others are likely to add their input as Angular 2 becomes more st
Cites spinningarrow · 2015-03 · Stack Overflow · on “Assigning dependencies in controllers using the ES6 class syntax”
In a video from ng-conf 2015 ( Angular 1.3 meets Angular 2.0 [this video] ), the syntax for using ES6 classes as controllers is shown as: class UnicornHype { constructor(unicornHorn, $q) { this.$q = $q; this.horn = unicornHorn } findUnicorn { return this.$q((resolve, reject) => { ... this.horn.thrust(); ... }); } } I see that the injected dependencies are assigned as instance properties and I'm wondering if that's a good way to do that. Since the controller's dependencies are usually singleton services, shouldn't they be shared by the instances? The reason they've done it like this is that methods that were previously on $scope (and therefore in the constructor function's body) are now on the obj
Cites Ashley Coolman · 2015-11 · Stack Overflow · on “Using typescript classes for services in angular 1.4.7”
I'm trying to implement services as classes as per this Ng Conf video Angular 1.3 meets Angular 2.0 - Michał Gołębiowski : [this video] I keep getting this error: TypeError: Cannot read property 'prototype' of undefined Code below: var angular = window['angular']; angular .module('myApp', []) .service('myService', [MyService]) .directive('test', function (myService) { return { restricts: 'E', template: 'Directive output: {{ctrl.message}}', controllerAs: 'ctrl', controller: function () { this.message = myService.message; } } }); /* // Works function MyService () { return { message: "service test" } } */ // Does not work class MyService { public message:string; constructor () { this.message = "serv