我在速度模板中有一个HTML表格.我想使用java脚本或jquery,comatibale和所有浏览器将html表数据导出到excel.我正在使用下面的脚本
<script type="text/javascript">
function ExportToExcel(mytblId){
var htmltable= document.getElementById('my-table-id');
var html = htmltable.outerHTML;
window.open('data:application/vnd.ms-excel,' + encodeURIComponent(html));
}
</script>
Run Code Online (Sandbox Code Playgroud)
这个脚本在Mozilla Firefox中工作正常,它弹出一个excel对话框,并要求打开或保存选项.但是当我在Chrome浏览器中测试相同的脚本时,它没有按预期工作,当点击按钮时,没有弹出的Excel.数据被下载到一个带有"文件类型:文件"的文件中,没有像.xls那样的扩展名 在chrome控制台中没有错误.
Jsfiddle的例子:
http://jsfiddle.net/insin/cmewv/
这在mozilla中运行良好,但在chrome中不行.
Chrome浏览器测试用例:
第一张图片:我点击导出到Excel按钮
结果:

我试图判断a中的项是否*ngFor是容器样式的第一个或最后一个元素.有没有办法做这样的事情?
<md-expansion-panel *ngFor="let item of items" *ngClass="{ 'first' : item.isFirst }">
<content></content>
</md-expansion-panel>
Run Code Online (Sandbox Code Playgroud)
感谢您提供的任何帮助!
在 Angular 9 中,可注入装饰器选项providedIn有一个名为any. root和 和有any什么区别?
在我使用的情况下,服务是否被视为单例any?
@Injectable({providedIn: 'any'})
class UsefulService {
}
Run Code Online (Sandbox Code Playgroud) typescript angular-services angular angular-dependency-injection
我正在尝试向材质表添加不同的过滤器.更确切地说,我正在尝试重现类似于以下GIF的内容

为此,我在以下Github线程中关注irowbin的响应,但根据他的指导原则,我无法真正生成我想要的内容
在Stackblitz或Github上有任何工作示例,所以我可以在mattable中关注并创建多个搜索过滤器吗?
material-design angular-material angular angular-material-5 angular-material-6
I think my Problem is that the API delivers an Object instead of an array. So i need to Modify the Object to be an Array ?
How could this be done ? Object.assign ? Or Pipe ? Does anyone have a proper example ? I'am still learning Angular this is my second Project so i need some help ;)
thy so far !
Here is my code
getting data from API ..cant change the API it delivers an Object …
如果我添加在angular.json文件中
"styles": [
"src/styles.css",
"src/utility/vendor/bootstrap/css/bootstrap.css",
"src/utility/vendor/font-awesome/css/fontawesome-all.min.css",
"src/utility/vendor/animate.css/animate.min.css",
"src/utility/vendor/slick-carousel/slick/slick.css",
"src/utility/css/front.css",
"src/utility/css/codepen.css"
],
Run Code Online (Sandbox Code Playgroud)
这些文件仅可用于index.html文件访问,而不能访问app.component.html或任何组件,甚至其他组件也不会使用与index.html相同的内容进行渲染,但是index.html可以正常工作
我的 ngAfterViewInit 函数未按预期工作。我感觉我在这里错过了一些东西。
ngOnInit() {
this.dataService.getUsers().subscribe((users) => {this.users = users) ;
}
ngAfterViewInit() {
if (document.getElementById('target')) {
document.getElementById('target').scrollIntoView({
behavior: 'auto',
block: 'center',
inline: 'center',
});
}
Run Code Online (Sandbox Code Playgroud)
所以基本上,在视图完成加载后,我使用ngAfterViewInint()函数滚动到当前项目。在里面ngOnInit(),如果我不打电话subscribe(),只是在那里放一个变量。它工作得很好。但我所问的情况并非如此。
setTimeOut()我通过使用inside解决了这个问题ngAfterViewInit()。但我不喜欢它。我不喜欢它依赖于超时这一事实。我认为会有更好的解决方案。有理想吗?谢谢大家。
我已将 npm 升级到最新版本。我的 Visual Studio 应用程序中的 npm 文件夹读取 v6.0.3,而我的 package.json 文件也对应于此版本 6.0.3。
但是每当我运行我的应用程序时,我都会收到错误“无法在浏览器上找到模块”
我相信 HttpClient 在 3x 以上的版本中使用,但显然安装了更高的版本。
应用程序模块.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import { RouterModule } from '@angular/router';
import { AppComponent } from './components/app/app.component';
import { NavMenuComponent } from './components/navmenu/navmenu.component';
import { HomeComponent } from './components/home/home.component';
import { FetchDataComponent } from './components/fetchdata/fetchdata.component';
import { CounterComponent } from './components/counter/counter.component';
import …Run Code Online (Sandbox Code Playgroud) 我有一个方法,它有一些可选参数,像这样,
initializeInteraction(opts: { type?: string; freehand?:boolean= false }) {
this._draw = this.drawService.initDraw({ drawtype: opts.type });
this._drawInteraction = this._draw.interaction;
this.mapService.addVector(this._draw.vector);
this.mapService.addInteraction(this._drawInteraction);
}
Run Code Online (Sandbox Code Playgroud)
我想仅在需要时将 的值设置freehand为true,否则我希望将其设置为false,
但是当我宣布这一点时
initializeInteraction(opts: { type: string; freehand?:boolean= false }) {}
Run Code Online (Sandbox Code Playgroud)
我收到一个错误
[ts] A type literal property cannot have an initializer. [1247]
Run Code Online (Sandbox Code Playgroud) 我正在尝试实现列大小调整和stick header。但是,如果我不使用列大小调整,则粘性标头可以很好地工作。如果同时实现这两种方法,则列调整大小是有效的,但粘性标头不起作用。
我使用了primeng的以下CSS作为粘性标头。
:host ::ng-deep .ui-table .ui-table-thead > tr > th {
position: -webkit-sticky;
position: sticky;
top: 70px;
}
@media screen and (max-width: 64em) {
:host ::ng-deep .ui-table .ui-table-thead > tr > th {
top: 100px;
}
}
Run Code Online (Sandbox Code Playgroud)
对于colum调整大小,我使用了以下代码[resizableColumns]="true", pResizableColumn
<p-table [columns]="cols" [value]="cars1" [resizableColumns]="true">
...
<th *ngFor="let col of columns" pResizableColumn>
Run Code Online (Sandbox Code Playgroud)
如果我删除resizbleColumns和pResizableColumn粘性标头工作正常。我怎样才能使它同时起作用呢?这是stackblitz和演示
angular ×9
typescript ×3
css ×2
html ×2
javascript ×2
ngfor ×2
primeng ×2
angular-dependency-injection ×1
angular5 ×1
angular6 ×1
api ×1
excel ×1
fetch ×1
jquery ×1
npm ×1
package.json ×1