如何将 angular.js 模块导入 angular 应用程序?
How can I import an angular.js module into an angular application?
Objective:我想将以下旋转木马 example 包含到 Angular 2+ 组件中。
包含此轮播的步骤涉及导入 'theta' 模块。我不确定这将如何与 Angular 2+ 依赖注入一起使用。以下 link 中提到的说明适用于 AngularJs 应用程序:https://theta-carousel.com/api.html#add-to-angularjs-app
如何在 Angular 2+ 应用程序中使用它?
你不能在 Angular2+ 中使用外部源代码,除非有一个 NPM 包,我认为 theta-carousel 没有它。您将不得不寻找其他方法来实现自己的轮播。
首先,也许您可以查看此 well-articulated article。
有几种方法可以将 AngularJs 外部包合并到 Angular 包中。
将其用作 jQuery 插件。这将需要 jQuery 以及可以包含在 angular.json 文件中的内容:
"scripts": [
"node_modules/jquery/dist/jquery.min.js",
"src/assets/js/theta-carousel.min.js"
]
组件文件:
import { Component, OnInit } from '@angular/core';
declare var $: any;
export class AppComponent implements OnInit {
ngOnInit(): void {
$('.example').theta_carousel({*/options*/})
- 创建混合 angularJs/angular 应用程序(不理想,也不推荐)。
Objective:我想将以下旋转木马 example 包含到 Angular 2+ 组件中。
包含此轮播的步骤涉及导入 'theta' 模块。我不确定这将如何与 Angular 2+ 依赖注入一起使用。以下 link 中提到的说明适用于 AngularJs 应用程序:https://theta-carousel.com/api.html#add-to-angularjs-app
如何在 Angular 2+ 应用程序中使用它?
你不能在 Angular2+ 中使用外部源代码,除非有一个 NPM 包,我认为 theta-carousel 没有它。您将不得不寻找其他方法来实现自己的轮播。
首先,也许您可以查看此 well-articulated article。
有几种方法可以将 AngularJs 外部包合并到 Angular 包中。
将其用作 jQuery 插件。这将需要 jQuery 以及可以包含在 angular.json 文件中的内容:
"scripts": [ "node_modules/jquery/dist/jquery.min.js", "src/assets/js/theta-carousel.min.js" ]
组件文件:
import { Component, OnInit } from '@angular/core';
declare var $: any;
export class AppComponent implements OnInit {
ngOnInit(): void {
$('.example').theta_carousel({*/options*/})
- 创建混合 angularJs/angular 应用程序(不理想,也不推荐)。