Last active
November 14, 2016 02:40
-
-
Save alshdavid/f783ad367bc1c77cb07412ba0ea2e099 to your computer and use it in GitHub Desktop.
angular2 popup input help
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
@Component({ | |
html: | |
" | |
<section *ngFor="status"> | |
<div> {{ msg }} </div> | |
<input id="popup_input" type="text" /> | |
<button id="popup_button">send</button> | |
</section> | |
" | |
}) | |
export class { | |
constructor (){} | |
status = false | |
msg | |
openPopup(msg){ | |
return new Promise((res) => { | |
this.status = true | |
this.msg = msg | |
//somehow return a promise with the input's data? | |
document.getElementById("popup_button").addEventListener("click", function(){ | |
this.status = false | |
res(document.getElementById("popup_input").value) | |
}) | |
}) | |
} | |
closePopup(){ | |
this.status = false | |
} | |
} |
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
how could I get it so that from anywhere I can just write | |
openMenu() | |
.then(res => { | |
//use response data | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment