作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
index.html http://pastie.org/10777655
app.js http://pastie.org/10777651
我是 AngularJS 的新手。有人可以解决这个问题吗?如果不起作用,请重新加载 Pastie url。
最佳答案
查看 ngCsv 文档发现您的应用程序存在错误。
1) ngCsv 模块依赖于您未包含的 ngSanitize。
2) ng-csv="getArray()" 可以是表达式、值或 promise 。但就你的情况而言,我认为有些问题。
var app = angular.module('mainApp',['ngSanitize','ngCsv']);
app.controller('myCtrl',function($scope,$http){
var endpoint = 'http://localhost:8080';
$scope.show_table = true;
$scope.ShowSearchTab= true;
$scope.hideTable = function(){
$scope.show_table = false;
};
$scope.ClickShow = function(){
$scope.ShowSearchTab = true;
};
$scope.test = [
{'companyname':'Company 1', 'streetaddress':'Address 1', 'executive':'exe 1', 'webaddress':'www.example1.com', 'dunsno':'xxx', 'leadid':'yyy'},
{'companyname':'Company 2', 'streetaddress':'Address 2', 'executive':'exe 2', 'webaddress':'www.example2.com', 'dunsno':'xxx', 'leadid':'yyy'},
{'companyname':'Company 3', 'streetaddress':'Address 3', 'executive':'exe 3', 'webaddress':'www.example3.com', 'dunsno':'xxx', 'leadid':'yyy'},
{'companyname':'Company 4', 'streetaddress':'Address 4', 'executive':'exe 4', 'webaddress':'www.example4.com', 'dunsno':'xxx', 'leadid':'yyy'}
]
$scope.getArray = function(){
return $scope.test;
}
});
工作 Plunkr 在这里 https://plnkr.co/edit/K5l3snujJ3GQtPyjRJLZ?p=preview
关于javascript - 如何将 Angular 生成的表从数据库导出为 csv 格式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36281153/
我是一名优秀的程序员,十分优秀!