Angular 角度数据表在角度6应用中的投掷误差
我在Angular应用程序中使用数据表。安装数据表后,我面临以下错误:Angular 角度数据表在角度6应用中的投掷误差,angular,datatables,angular6,Angular,Datatables,Angular6,我在Angular应用程序中使用数据表。安装数据表后,我面临以下错误: ReferenceError: angular is not defined at Object../node_modules/angular-datatables/dist/angular-datatables.js 有人能告诉我该怎么做才能继续吗?您正在使用库forAngularJS。使用insteed要使用角度数据表,需要安装节点10或更高版本和NPM 6或更高版本 该演示是在8.Y.Z版本中开发的,Angu
ReferenceError: angular is not defined
at Object../node_modules/angular-datatables/dist/angular-datatables.js
有人能告诉我该怎么做才能继续吗?您正在使用库for
AngularJS
。使用insteed要使用角度数据表,需要安装节点10或更高版本和NPM 6或更高版本
该演示是在8.Y.Z版本中开发的,Angular CLI的旧版本和新版本可能需要具有不同的配置
在使用NPM获得最新版本之前,您需要安装其依赖项:
npm install jquery --save
npm install datatables.net --save
npm install datatables.net-dt --save
npm install angular-datatables --save
npm install @types/jquery --save-dev
npm install @types/datatables.net --save-dev
将脚本和样式属性中的依赖项添加到angular.json:
{
"projects": {
"your-app-name": {
"architect": {
"build": {
"options": {
"styles": [
"node_modules/datatables.net-dt/css/jquery.dataTables.css"
],
"scripts": [
"node_modules/jquery/dist/jquery.js",
"node_modules/datatables.net/js/jquery.dataTables.js"
],
...
}
在应用程序的适当级别导入DataTablesModule
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { DataTablesModule } from 'angular-datatables';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
DataTablesModule
],
providers: [],
bootstrap: [ AppComponent ]
})
export class AppModule {}
如果遇到以下错误:
ERROR in Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 194:50 in the original .ts file), resolving symbol NgModule in /home/l-lin/projects/angular-datatables/demo/node_modules/angular-datatables/node_modules/@angular/core/core.d.ts, resolving symbol DataTablesModule in /home/l-lin/projects/angular-datatables/demo/node_modules/angular-datatables/src/angular-datatables.module.ts, resolving symbol DataTablesModule in /home/l-lin/projects/angular-datatables/demo/node_modules/angular-datatables/src/angular-datatables.module.ts
请更新您的tsconfig.json并添加以下块:
{
"compilerOptions": {
...
"paths": {
"@angular/*": [
"../node_modules/@angular/*"
]
}
}
}
可能重复的