码迷,mamicode.com
首页 > Web开发 > 详细

[RxJS] Getting Input Text with Map

时间:2016-03-11 06:27:19      阅读:241      评论:0      收藏:0      [点我收藏+]

标签:

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/rxjs@5.0.0-beta.1/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

标签:

原文地址:http://www.cnblogs.com/Answer1215/p/5264165.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!