Skip to content

Instantly share code, notes, and snippets.

Last active Oct 25, 2015
What would you like to do?
ng-forward ng1 migration (part 1)
import { componentAModule } from './component-a';
angular.module('app', [componentAModule]);
import { Component, Inject, bundle } from 'ng-forward';
// We'll convert componentA first
// Warning: Because we haven't converted serviceA yet,
// ComponentA will just have to trust that serviceA will be available
// We can inject serviceA by name using a string, which can reference any ng1 provider
selector: 'component-a'
export class ComponentA {
constructor(serviceA) { }
export default bundle('componentAModule', ComponentA).name;
(function() {
.directive('componentB', function() {
return ['serviceB', function linkFn(serviceA){}]
(function() {
.service('serviceA', function() {});
(function() {
.service('serviceB', function() {});

This comment has been minimized.

Copy link

@david-gang david-gang commented Oct 25, 2015


There are a couple of things i want to ensure:

  • bundle can just be used once to bundle all components and not incrementally.
  • angular.module can be called multiple times

Shouldn't it be in service-a.js angular.module('componentAModule') ? I think the intention was to demonstrate that the module created by the bundle function can be called further through the angular.module syntax to register additional fields. Is this correct?

This would also enable us to migrate a big module in parts. Is this correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment