Skip to content

Instantly share code, notes, and snippets.

@timkindberg timkindberg/app.js
Last active Oct 25, 2015

Embed
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
@Component({
selector: 'component-a'
})
@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){}]
});
})()
(function() {
angular.module('app')
.service('serviceA', function() {});
})()
(function() {
angular.module('app')
.service('serviceB', function() {});
})()
@david-gang

This comment has been minimized.

Copy link

commented Oct 25, 2015

Hi,

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
You can’t perform that action at this time.