Skip to content

Instantly share code, notes, and snippets.

@timkindberg timkindberg/app.js
Created Oct 22, 2015

Embed
What would you like to do?
ng-forward ng1 migration (part 2)
import { componentAModule } from './component-a';
angular.module('app', [componentAModule]);
import { Component, Inject, bundle } from 'ng-forward';
import { ServiceA } from './service-a';
// We converted this file in part 1
// Now we have converted serviceA so we can use properly by
// adding it to our providers array (which ensures it is bundled with this component)
// We can also now reference it by object instead of string in the @Inject call
@Component({
selector: 'component-a',
providers: [ServiceA]
})
@Inject(ServiceA)
export class ComponentA {
constructor(serviceA) { }
}
export default bundle('componentAModule', ComponentA).name;
(function() {
angular.module('app')
.directive('componentB', function() {
return ['serviceB', function linkFn(serviceA){}]
});
})()
import { Injectable } from 'ng-forward';
@Injectable()
export class ServiceA{ }
(function() {
angular.module('app')
.service('serviceB', function() {});
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.