【发布时间】:2016-03-15 18:21:36
【问题描述】:
我可以轻松地将 angular2 提供程序添加到 UpgradeAdapter:
import { HTTP_PROVIDERS } from 'angular2/http';
upgradeAdapter.addProvider(HTTP_PROVIDERS);
我可以升级一个 ng1 指令(组件)也很容易:
const DirectiveNg1 = upgradeAdapter.upgradeNg1Component('DirectiveNg1');
但是我在很多地方都需要DirectiveNg1,并且想在 angular2 组件中使用它们。是否有可能以某种方式获得参考?
目前我在我的 angular2 组件中指定了以下内容并且它可以工作,但我只想在 main.js 文件中使用一次upgradeNg1Component('DirectiveNg1')。
const DirectiveNg1 = upgradeAdapter.upgradeNg1Component('DirectiveNg1');
// how can I replace the line above, and get a reference from the UpgradeAdapter
@Component({
directives: [DirectiveNg1],
...
})
【问题讨论】:
标签: angularjs-directive angular angular2-upgrade