Created
April 27, 2017 19:02
-
-
Save Ibro/42f6b3f6f0650e362697cc6eccbe8bd7 to your computer and use it in GitHub Desktop.
On Click -> Add stuff to html - Coding Blast - www.codingblast.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Observable} from 'rxjs'; | |
let btnFun = document.getElementById('btnFun'); | |
let divMain = document.getElementById('divMain'); | |
let clicksSource = Observable.fromEvent(btnFun, 'click'); | |
clicksSource | |
.scan((s) => <number>s + 1, 0) | |
.forEach(number => addStuffToHtml(number)); | |
function addStuffToHtml(number) { | |
let span = document.createElement('span'); | |
span.innerText = ` ${number}`; | |
divMain.appendChild(span); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment