不能使用变量作为参数
问题描述:
我试图在这个URL中插入参数,但我无法让它工作。这里是我的代码:不能使用变量作为参数
filterFunction(newValue, parameter){
this.workorderservice.searchWorkorders(1, 20, {sort: {}, search: {predicateObject: {'workorder.location.street': newValue}}, pagination: {start: 0}})
.subscribe(data =>{ this.rows = data.json()
this.links = this.parselink.parse(data.headers.get('link'))
console.log(this.rows)
})
}
我尝试用参数
答
不能使用参数名称一样,以取代“workorder.location.street”。即使你的问题有点含糊,我想你应该这样做:
filterFunction(newValue, parameter) {
let predicateObject: any = {};
predicateObject[parameter] = newValue;
this.workorderservice.searchWorkorders(1, 20, {sort: {}, search: {predicateObject: predicateObject}, pagination: {start: 0}})
.subscribe(data =>{ this.rows = data.json()
this.links = this.parselink.parse(data.headers.get('link'))
console.log(this.rows)
})
}
谢谢你,这帮助了我的问题。 – user2843943