Ok, I'm really struggling with this one. I looked everywhere I could for a solution but didn't find it even though there are quite a few similar questions.
I have a class. I need only one instance, so I made service for it:
services.factory('PlayerService', ->
new Player()
)
As you can see it is some kind of player. I need my view to update when the song changes.
Here is an extremely simplified demo plnk that exposes the problem: http://plnkr.co/edit/L3WndT
And here is what I tried based on this question. None of solutions work.
View
<div ng-controller="PlayerController">
{{ player.currentSong }}
</div>
First one
PlayerController = ($scope, PlayerService) ->
$scope.player = PlayerService
return
Second one
PlayerController = ($scope, PlayerService) ->
$scope.$watch(
'myApp.services.PlayerService'
(newval, oldval) ->
$scope.currentSong = newval
true
)
return