I can add angular2 providers easy to the UpgradeAdapter:
import { HTTP_PROVIDERS } from 'angular2/http';
upgradeAdapter.addProvider(HTTP_PROVIDERS);
I can upgrade an ng1 directives (component) also quite easy:
const DirectiveNg1 = upgradeAdapter.upgradeNg1Component('DirectiveNg1');
But I need DirectiveNg1
in many places and would like to use them in angular2 components. Is it somehow possible to get a reference back?
At the moment I have specified the following in my angular2 component and it works, but I'd like to only upgradeNg1Component('DirectiveNg1')
once in me main.js file.
const DirectiveNg1 = upgradeAdapter.upgradeNg1Component('DirectiveNg1');
// how can I replace the line above, and get a reference from the UpgradeAdapter
@Component({
directives: [DirectiveNg1],
...
})
I know this post is a little old but this took me ages of internet searching to work out. I don't think the documentation for this is very good.
This simplest way is if you're just going to have one module. you can define it as follows.
now DirectiveNg1 can be used in angular2 components.