首页 > 解决方案 > 如何在 Angular 6 中使用 angular-timelinejs3?

问题描述

在此处输入图像描述对不起,正如我提到的。我是 Angular 6 的新手。我已经看到了这个链接https://www.npmjs.com/package/angular-timelinejs3?activeTab=readme,当我尝试在 Angular 6 中进行操作时。我卡在中间,因为他们说“将依赖项添加到时间轴您的角度模块:ngTimeline”这意味着哪一个?

我安装了 angular-timelinejs3。在 index.html 中添加了 css 和 javascript。当我在 app.component.html 中输入指令时?

In Index.html

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Trial</title>
  <link rel="stylesheet" href="https://cdn.knightlab.com/libs/timeline3/latest/css/timeline.css">
  <script src="/node_modules/angular/angular.js"></script>
  <script src="https://cdn.knightlab.com/libs/timeline3/latest/js/timeline.js"></script>
  <base href="/">

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>

  <app-root></app-root>
</body>
</html>
In app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
//import { NgTimelineModule } from 'ng-timeline';
@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

In app.component.html

<timeline  control="timeline" height="80vh" options="options"></timeline >
In app.component.ts
import { Component, OnInit } from '@angular/core';
//import  'ng-timeline';
//import 'angular-timelinejs3';


//import  * as timeline from 'ng-timeline';
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
  ngOnInit(): void {
  }

}

标签: javascriptangulartimeline.js

解决方案


这个 Angular-timelinejs3 包只支持 Angular JS。缺少对 Angular 2+ 的支持。请找到支持 Angular 2+ 的备用时间线包。


推荐阅读