Created
May 20, 2020 02:29
-
-
Save Danetag/cb7ed4b471d413aa800ae146ec1a08cb to your computer and use it in GitHub Desktop.
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
/* In a web component */ | |
// Private function to get the data from the "<script>" element | |
selectData = () => { | |
const options = this.slotContainerRef.querySelector('script'); | |
const optionsJSON = !!options && JSON.parse(options.innerHTML); | |
if (optionsJSON) { | |
return optionsJSON; | |
} | |
return null; | |
} | |
// Also provide a Method to be able to inject the data via JS | |
@Method async setData(data) { | |
this.data = data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment