Created
October 22, 2015 18:28
-
-
Save timkindberg/78226481690a20f9f2a0 to your computer and use it in GitHub Desktop.
ng-forward ng1 migration (part 2)
This file contains hidden or 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 hidden or 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'; | |
| 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; |
This file contains hidden or 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 hidden or 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 { Injectable } from 'ng-forward'; | |
| @Injectable() | |
| export class ServiceA{ } |
This file contains hidden or 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