brandly / angular-youtube-embed

:tv: Embed a YouTube player with a simple directive

Home Page:http://brandly.github.io/angular-youtube-embed/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't pass player to factory to be shared between nested directives

adamzerner opened this issue · comments

Sorry, I'm on a phone right now, so I can't do a lot. It looks like you want a single player reference to be shared amongst various controllers or directives or what have you.

If I understand correctly, you should try using a service instead of a factory, so that you'll have a singleton that can be passed about.

Let me know if this helps. If not, could you supply a plunker or a jsfiddle? Thanks and best of luck

It looks like you want a single player reference to be shared amongst various controllers or directives or what have you.

Correct.

If I understand correctly, you should try using a service instead of a factory, so that you'll have a singleton that can be passed about.

I don't think the distinction between service and factory matters. From what I understand, both are singletons and the only difference is that services are instantiated using the new keyword. I found this cheatsheet helpful.

Let me know if this helps. If not, could you supply a plunker or a jsfiddle? Thanks and best of luck

I couldn't figure out how to include your library in the plunker, but my SO question should have enough information and I just edited it to include my code on GitHub.

here's an example of passing a player reference around, via a factory: https://jsfiddle.net/fx680Lhr/