有没有办法将字符串参数与观察者 next() 方法参数连接起来?
Is there a way to concatenate a string parameter with observer next() method parameter?
我有这样的方法:
public getContentForGivenFields(fields: any) {
this.content$.subscribe({
next: res => {
console.log(res.fields); // res.first_name => {first_name object}
}
})
}
调用第一个方法的第二个方法:
public getPersonName() {
this.service.getContentForGivenFields("first_name");
}
我想要第一个方法获取它的参数并按照我上面显示的方式使用它。如果您知道其他方法 - 请分享!
谢谢:)
您想传递几个名称并连接这些字段?还是只有一个 属性?
如果一个那么 res[fieldName]
否则 fields.map(field => res[field]).join(' ')
或类似的东西;
或者您可以使用 pluck
运算符,然后连接结果
我有这样的方法:
public getContentForGivenFields(fields: any) {
this.content$.subscribe({
next: res => {
console.log(res.fields); // res.first_name => {first_name object}
}
})
}
调用第一个方法的第二个方法:
public getPersonName() {
this.service.getContentForGivenFields("first_name");
}
我想要第一个方法获取它的参数并按照我上面显示的方式使用它。如果您知道其他方法 - 请分享!
谢谢:)
您想传递几个名称并连接这些字段?还是只有一个 属性?
如果一个那么 res[fieldName]
否则 fields.map(field => res[field]).join(' ')
或类似的东西;
或者您可以使用 pluck
运算符,然后连接结果