我有一个 HTTP 请求
searchService() {
return this.httpClient.get(URL);
}
Run Code Online (Sandbox Code Playgroud)
我是这样订阅的
search() {
this.service.searchService().subscribe((data) => { });
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,这需要几秒钟的时间,如果有人使用不同的搜索键多次单击,结果取决于请求的速度。
所以,我想取消所有以前的订阅并只保留最后的搜索
<form [formGroup]="form">
<select name="area_id" formControlName="area_id">
<option value="1">Value 1</option>
<option value="2">Value 2</option>
<option value="3">Value 3</option>
</select>
</form>
<pre>{{ form.value | json }}</pre>
Run Code Online (Sandbox Code Playgroud)
如果我选择一个选项,则该值将为字符串.如何强制该值为整数?
我想用一些正则表达式替换一些括号之间的空格.如果我使用正则表达式只替换一些空格(只有唯一的对).
字符串可能有其他空格,但我只想要paranthesis之间的空格.
var mystring = ") ) ) ) ) )";
console.log(mystring);
mystring = mystring.replace(/\)\s\)/g, "))");
console.log(mystring);
Run Code Online (Sandbox Code Playgroud)
输出是:
) ) ) ) ) )
)) )) ))
Run Code Online (Sandbox Code Playgroud)
但是我想要这个输出:
) ) ) ) ) )
))))))
Run Code Online (Sandbox Code Playgroud) 为什么这不起作用?
import { forkJoin } from 'rxjs';
import { ActivatedRoute } from '@angular/router';
constructor(
private route: ActivatedRoute
) {}
ngOnInit(): void {
let parent = this.route.parent.params;
let child = this.route.params;
forkJoin(
parent,
child,
(p, c) => {
console.log(p);
console.log(c);
}
)
}
Run Code Online (Sandbox Code Playgroud)
仅供参考(rxjs6)
我有一个数组
[1,2,3,4,5]
我想向右移动“2”(当时 1 个位置)或向左移动“2”
我们可以用 RxJS Operators 做到这一点吗?