-
-
Save ftrivino/58a4e664b8dee292037d5eff3c1c6f3e 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