[RxJS] Getting Input Text with Map
Posted Answer1215
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[RxJS] Getting Input Text with Map相关的知识,希望对你有一定的参考价值。
By default, Inputs will push input events into the stream. This lesson shows you how to use map
to convert the input event into the text you actually want.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <script src="https://npmcdn.com/@reactivex/[email protected]/dist/global/Rx.umd.js"></script> <title>JS Bin</title> </head> <body> <input type="text" id="input"> </body> </html>
const input = document.querySelector(‘#input‘); const input$ = Observable.fromEvent(input, ‘input‘) .map(event => event.target.value); input$ .subscribe((x)=> console.log(x));
以上是关于[RxJS] Getting Input Text with Map的主要内容,如果未能解决你的问题,请参考以下文章