Issue #1691Opened December 28, 2018by AkibDeraiya1230 reactions

How to use variable/function outside of the script

Question

Hello @artf , How can i access the variable as well functions which is outside of the script.

My code is like,

var temp = {};

function fnName() {
    // Here is some script execution and will do it on global variables
}

bm.add("image-cropper",
    {
        label: '<div class="gjs-block-label">Image Cropper</div>',
        tab: "2",
        content: {
            script: function () {
                // But here i am getting temp is undefinded.
                if (Object.keys(temp).length === 0) {
                    temp = {};
                }
                
                temp = {
                    a: "abcd",
                    b: "xyz"
                }
                // Here is the further code and using temp.
                // As well i also need to use `fnName()` function in some cases.
            },
            content: '<div><h1>Hello</h1><img id="staticId" onclick="jsFunc(staticId)" src="imagePath" /><div>'
        }
    }
)

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)

lock[bot]January 4, 20200 reactions

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.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.