Last active
October 25, 2015 07:12
-
-
Save timkindberg/95166e525685db1f6394 to your computer and use it in GitHub Desktop.
ng-forward ng1 migration (part 1)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { componentAModule } from './component-a'; | |
angular.module('app', [componentAModule]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
angular.module('app') | |
.directive('componentB', function() { | |
return ['serviceB', function linkFn(serviceA){}] | |
}); | |
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
angular.module('app') | |
.service('serviceA', function() {}); | |
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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
Hi,
There are a couple of things i want to ensure:
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?