Skip to content

Instantly share code, notes, and snippets.

@alshdavid
Last active November 14, 2016 02:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alshdavid/f783ad367bc1c77cb07412ba0ea2e099 to your computer and use it in GitHub Desktop.
Save alshdavid/f783ad367bc1c77cb07412ba0ea2e099 to your computer and use it in GitHub Desktop.
angular2 popup input help
@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
}
}
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