首页 > Web开发 > 详细

[RxJS] Getting Input Text with Map

时间:2016-03-11 06:24:18      阅读:126      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!