angular-ecmascript | Build an AngularJS app using ES6 's class system | Script Programming library
kandi X-RAY | angular-ecmascript Summary
kandi X-RAY | angular-ecmascript Summary
Build an AngularJS app using ES6's class system
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of angular-ecmascript
angular-ecmascript Key Features
angular-ecmascript Examples and Code Snippets
Community Discussions
Trending Discussions on angular-ecmascript
QUESTION
I am using JS, Angular, and Meteor to develop a web app that uses the Youtube api. In the constructor of one of my controllers I create the youtube player object by following the youtube api process. However, when I try to reference the seemingly global "player" object in a later function within the same controller, it appears to be out of scope.
I was wrestling with this issue for days because the "player" variable seems to be global (there is no var proceeding it) until I ran across the frowned upon practice of using window.variableName. I can only get the playPause function to recognize the player object if I use window.player = ... Does anyone have any idea why the player object is not already global to its containing controller and functions?
I am still learning my way around javascript scoping intricacies as well as ECMA class style, so any help would be appreciated.
My code:
...ANSWER
Answered 2017-Jan-24 at 21:10So the problem is that you define your player as a local variable in your class constructor. As such, that variable will not be visible anywhere else - like in your playPauseToggle function.
Instead, why not make your player an attribute of your class instance?
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install angular-ecmascript
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page