【发布时间】:2019-02-19 14:28:07
【问题描述】:
我已按照链接https://www.npmjs.com/package/angular2-csv 中给出的步骤在 ASP.Net Core 的 Angular 4 应用程序中导出到 csv 文件,但出现错误“无法解析 Angular2Csv 的所有参数:(?, ?, ?) 。”
请在下面找到我已经完成的步骤,
-
已经使用 npm 安装了 angular2-csv
npm install --save angular2-csv@0.2.5 -
然后我已经在 app.module.server.ts 中导入了
import { Angular2Csv } from 'angular2-csv';
并添加了提供者,
@NgModule({
declaration:[...],
imports:[...],
providers:[Angular2Csv]
})
-
然后我创建了用于导出到 csv 的选项和数据
import { Angular2Csv } from 'angular2-csv'; @Component({ selector: 'home', templateUrl: './my.component.html', styleUrls: ['./my.component.css'], encapsulation: ViewEncapsulation.None }) export class MyComponent { options = { fieldSeparator: ',', quoteStrings: '"', decimalseparator: '.', showLabels: false, headers: [], showTitle: true, title: 'asfasf', useBom: false, removeNewLines: true, keys: ['approved','age','name' ] }; data = [ { name: "Test, 1", age: 13, average: 8.2, approved: true, description: "using 'Content here, content here' " }, { name: 'Test 2', age: 11, average: 8.2, approved: true, description: "using 'Content here, content here' " }, { name: 'Test 3', age: 10, average: 8.2, approved: true, description: "using 'Content here, content here' " } ]; } -
我的模板看起来像这样
<angular2csv [data]="data" filename="test.csv" [options]="options"></angular2csv>
当我构建和运行解决方案时,出现下面提到的错误
“无法解析 Angular2Csv 的所有参数:(?, ?, ?)”
请帮我解决这个问题
【问题讨论】:
标签: angular asp.net-core-mvc asp.net-core-2.0