How to access global functions in component markup
See original GitHub issueI’m not able to access global functions in the markup of a component.
var mySingleton = { myFunction : function() { } }
<my_component v-on:click="mySingleton.myFunction()"></my_component>
mySingleton will be UNDEFINED because of:
(function(scope /**/) { return scope.window.mySingleton.myFunction(); })
If I try to access via
<my_component
v-on:click=“window.mySingleton.myFunction()”"></my_component>`
It is still UNDEFINED because of:
(function(scope /**/) { return scope.window.mySingleton.myFunction(); })
Shouldn’t at least case 2 work so that vue does not prepend scope.
because I try to access window.
?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:13 (3 by maintainers)
Top Results From Across the Web
Write global functions to use in all components in angular
1. create your global function service, i.e. 'funcs.services.ts' under 'services' directory: import { Injectable } from '@angular/core'; ...
Read more >How does one access global variables, like $setup, in a ...
Some info is "some global variables are accessible in components" and "none are accessible". So that being the case would a call to...
Read more >How to Use a Globally Defined Script Inside a React Component
A global variable is defined inside a script tag independent of the React app. This global variable can be data that needs to...
Read more >Configure the Component Markup and Design Resource for a ...
Mark your resources with access="global" to make it usable outside of your own org, such as to make a component usable by a...
Read more >How do I use a global function from a custom framework in an ...
I have a custom framework that is loading fine with my Angular app. I can access its global functions via the Console when...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Vue.prototype.whatever = yourGreatLibrary
should work.https://jsbin.com/pemugaketi
Understood. So what is your recommended way to access singletons from component markup without adding them to data (which would make them reactive and this is not wanted). In fact no reactivity here is intended.