How to use variable/function outside of the script
You can't, they're not in the same context, read carefully this page https://grapesjs.com/docs/modules/Components-js.html You need to copy your global variables inside the script property or you can inject them in the canvas as a dependecy
Read full answer below βQuestion
Hello @artf , How can i access the variable as well functions which is outside of the script. My code is like, I am using angular.js(Angular1). And the above code is for the controller file. Can you please assist me how can i use this global variable as well function in my script?
Answers (2)
You can't, they're not in the same context, read carefully this page https://grapesjs.com/docs/modules/Components-js.html You need to copy your global variables inside the script property or you can inject them in the canvas as a dependecy
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1733
How to remove script tag which is added by add block manager script
Hello @artf I want to export final/production based html content excluding the script(Only which is added by block manager). Suppose i am a...
Issue #1524
Howto add Blocks?
Hello all, it turns me crazy but I do not understand how to add blocks. I can write them myself following tutorial, but when I load plugin,...
Issue #980
[BUG] Related with task https://github.com/artf/grapesjs/issues/873
Hello, After restoring editor from db still have some part of bug present. It seems inside of script: function () traits will have old valu...
Issue #1836
How to add !important in all the generated apis
Hello @artf, While i am going to edit some html from editor with the help of css then i need to add !important into all the css which is ch...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins βPremium plugins ship with support, regular updates, and production-ready features β save days of integration work.
Browse premium plugins βRelated tutorials
In-depth guides on the same topic.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.