我正在使用带有ag-grid数据表的角度5,我无法使用cellRenderer从单元格触发点击事件,这里如何使用我的ag-grid-> colDefs
this.columnDefs = [
{headerName: '#', rowDrag: true, width: 75},
{headerName: 'One', field: 'fieldName',
cellRenderer : function(params){
return '<div><button (click)="drop()">Click</button></div>'
}
}
];
drop() {
alert("BUTTON CLICKEFD")
}
Run Code Online (Sandbox Code Playgroud)
如果正在使用 onClick="alert("123")" ->它有效,但是我无法使用onClick="drop()"它会抛出未定义的信息,
我也在cellRenderer内部尝试过-> params = params.$scope.drop = this.drop;
如果在使用gridOptions angularCompileRows : true时抛出错误,Cannot read property '$apply' of undefined.
是否需要安装ag-grid enterprise?
如何将所有Double引号替换为打开和关闭大括号.
let str = "This" is my "new" key "string";
Run Code Online (Sandbox Code Playgroud)
我试过这个正则表达式
str.replace(/"/,'{').replace(/"/,'}')
Run Code Online (Sandbox Code Playgroud)
但我最终得到了这个:
{This} is my "new" key "string"
Run Code Online (Sandbox Code Playgroud)
这里只有第一个字正在改变,但我想改变所有的话.我希望结果如下:
{This} is my {new} key {string}
Run Code Online (Sandbox Code Playgroud)
提前致谢.
我的 utils 服务使用 express 框架从 mysql 数据库返回数据
import { Injectable } from '@angular/core';
import { Http, HttpModule, Headers, RequestOptions } from '@angular/http';
import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
@Injectable()
export class UtilsService implements OnInit{
public authData : any[];
constructor(private http : Http) {
}
ngOnInit() { }
getUserData() {
const reqData = JSON.parse(localStorage.getItem('AuthUser'));
return this.http.post('/get/logindata',reqData)
.map(result => result.json().data);
}
}
Run Code Online (Sandbox Code Playgroud)
我的组件部分
import { Component, OnInit } from '@angular/core';
import { UtilsService …Run Code Online (Sandbox Code Playgroud) javascript ×3
angular5 ×2
typescript ×2
ag-grid ×1
ag-grid-ng2 ×1
angular ×1
ecmascript-6 ×1
regex ×1
replace ×1
string ×1