Last active
September 6, 2017 02:23
-
-
Save bonoweb/0c7330ebd6110b698830cf5b0ec61f08 to your computer and use it in GitHub Desktop.
leaflet ionic 2 bind click on popup using attribute data-click
This file contains hidden or 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
constructor(public navCtrl: NavController, | |
public platform: Platform, | |
private iab: InAppBrowser, | |
private elementRef: ElementRef, | |
private renderer: Renderer, | |
) { | |
this.platform = platform; | |
this.elementRef = elementRef; | |
this.renderer = renderer; | |
renderer.listen(elementRef.nativeElement,'click',(event) => { | |
let element = event.target as HTMLElement; | |
if (element.tagName.toLowerCase() === "a") { | |
let l = element.getAttribute("data-click"); | |
if(l != null) { | |
console.log(l); | |
this.launch(l); | |
} | |
} | |
}); | |
} | |
public launch = (url) => { | |
this.platform.ready().then(() => { | |
let options = 'location=yes,toolbar=yes,hidden=no'; | |
const browser = this.iab.create(url); //,"_blank", options); | |
browser.show(); | |
}); | |
}; | |
////////////////////////////////////// | |
//per il popup di leaflet: | |
let popup = layer.bindPopup("<strong>"+feature.properties.popupContent + | |
"</strong><br><a data-click='http://www.example.com' href='#'>Link</a>"); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment