我可以在Angular2应用程序中使用Angular1插件吗?

时间:2020-12-28 21:04:37

I am very new to Angular 2 and would like to know if Angular 1 plugins can be used in Angular 2. I have used ng-knob in ionic 1 app. Some suggested to use jQuery knob instead but I really want to use ng-knob as it has many more options.

我是Angular 2的新手,想知道Angular 1插件是否可用于Angular 2.我在离子1应用程序中使用了ng-knob。有人建议使用jQuery旋钮,但我真的想使用ng-knob,因为它有更多选项。

Is it possible to use ng-knob in angular 2? Even if there is a harder way I would not hesitate to try it but I really wan't to use ng-knob.

是否可以在角度2中使用ng-knob?即使有一个更难的方法我会毫不犹豫地尝试它但我真的不想使用ng-knob。

Any help with sample code is greatly appreciated.

任何有关示例代码的帮助都非常感谢。

2 个解决方案

#1


1  

As Angular2 framework is different from Angular1 framework, I'm afraid to say that you can't use Angular1 plugin(s) for Angular2.

由于Angular2框架与Angular1框架不同,我不敢说你不能为Angular2使用Angular1插件。

Angular2 is a new framework and recently became stable. So, if you are looking for Angular2 plugin(s), its very hard to find them(as of now) as community is still developing Angular2 plugin(s).

Angular2是一个新框架,最近变得稳定。因此,如果您正在寻找Angular2插件,那么很难找到它们(截至目前),因为社区仍在开发Angular2插件。

#2


0  

Check out the Upgrading with The Upgrade Adapter section in angular.io - point 2 and other sections till 8.

查看angular.io中的升级适配器升级部分 - 第2点和其他部分,直到8。

https://angular.io/docs/ts/latest/guide/upgrade.html

Use angular.umd.js file instead of angular.dev.js or angular.js for 2.x. It supports both angular1 application and angular2 application to run side by side. This way you can use 1.x plugin with angular 1.x application and still run angular 2.x application side by side. You can use Zone.js to merge two way binding between angular 1.x application and 2.x application.

对于2.x,使用angular.umd.js文件而不是angular.dev.js或angular.js。它支持angular1应用程序和angular2应用程序并排运行。这样你可以使用1.x插件与角1.x应用程序,并仍然并排运行角度2.x应用程序。您可以使用Zone.js合并角度1.x应用程序和2.x应用程序之间的双向绑定。

But this can be complex and if you are not comfortable with advanced hacks, you should take the answer of using 1.x plugins in 2.x versions. Unless you are ready to port your 1.x plugin to 2.x plugin yourself.

但这可能很复杂,如果你对高级黑客不熟悉,你应该回答在2.x版本中使用1.x插件。除非你准备好自己将1.x插件移植到2.x插件。

Zone.js intro - https://www.youtube.com/watch?v=V9Bbp6Hh2YE Good resource from Misko.

Zone.js介绍 - https://www.youtube.com/watch?v=V9Bbp6Hh2YE来自Misko的好资源。

#1


1  

As Angular2 framework is different from Angular1 framework, I'm afraid to say that you can't use Angular1 plugin(s) for Angular2.

由于Angular2框架与Angular1框架不同,我不敢说你不能为Angular2使用Angular1插件。

Angular2 is a new framework and recently became stable. So, if you are looking for Angular2 plugin(s), its very hard to find them(as of now) as community is still developing Angular2 plugin(s).

Angular2是一个新框架,最近变得稳定。因此,如果您正在寻找Angular2插件,那么很难找到它们(截至目前),因为社区仍在开发Angular2插件。

#2


0  

Check out the Upgrading with The Upgrade Adapter section in angular.io - point 2 and other sections till 8.

查看angular.io中的升级适配器升级部分 - 第2点和其他部分,直到8。

https://angular.io/docs/ts/latest/guide/upgrade.html

Use angular.umd.js file instead of angular.dev.js or angular.js for 2.x. It supports both angular1 application and angular2 application to run side by side. This way you can use 1.x plugin with angular 1.x application and still run angular 2.x application side by side. You can use Zone.js to merge two way binding between angular 1.x application and 2.x application.

对于2.x,使用angular.umd.js文件而不是angular.dev.js或angular.js。它支持angular1应用程序和angular2应用程序并排运行。这样你可以使用1.x插件与角1.x应用程序,并仍然并排运行角度2.x应用程序。您可以使用Zone.js合并角度1.x应用程序和2.x应用程序之间的双向绑定。

But this can be complex and if you are not comfortable with advanced hacks, you should take the answer of using 1.x plugins in 2.x versions. Unless you are ready to port your 1.x plugin to 2.x plugin yourself.

但这可能很复杂,如果你对高级黑客不熟悉,你应该回答在2.x版本中使用1.x插件。除非你准备好自己将1.x插件移植到2.x插件。

Zone.js intro - https://www.youtube.com/watch?v=V9Bbp6Hh2YE Good resource from Misko.

Zone.js介绍 - https://www.youtube.com/watch?v=V9Bbp6Hh2YE来自Misko的好资源。