Skip to content

Instantly share code, notes, and snippets.

@timkindberg
Created October 22, 2015 18:28
Show Gist options
  • Save timkindberg/78226481690a20f9f2a0 to your computer and use it in GitHub Desktop.
Save timkindberg/78226481690a20f9f2a0 to your computer and use it in GitHub Desktop.
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