2016-11-22 93 views
1

我試圖在這個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) 
     }) 

} 

我嘗試用參數

回答

3

不能使用參數名稱一樣,以取代「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) 
     }) 

    } 
+0

謝謝你,這幫助了我的問題。 – user2843943

相關問題