我一直在关注将AngularJS应用程序更新到Angular应用程序的官方文档:https://angular.io/guide/upgrade
我有一些为AngularJS准备的插件/模块,我需要使用它们 . 是否可以使用AngularJS组件并在Angular应用程序中使用它们而不使用指令而不转换为typescript等作为混合应用程序?在此官方文档中,展示了如何制作混合应用程序,其中AngularJS组件完全转换为Angular .
例:
angular.module('my-module', ['templates-my-module'])
.service('myService', ['$q', MyService])
.component('myCustom', {
templateUrl: 'myCustomComponent.tpl.html',
controller: ['__env', '$scope', '$http', 'myService', '$timeout', MyCustomComponent]
});
function MyService($q) {
...
}
如何在Angular中使用此模块只需调用:
<my-custom-component></my-custom-component>
否则看起来重新编写插件会花费更短的时间 .