I'm creating a list of songs to play. I want a play/pause toggle button to the left of each song. Right now, I can't seem to get the play button to only toggle for one song within an ng-repeat. Can anyone help? The only other solution I saw that was applicable, AngularJS - using ng-show within ng-repeat, seems to have written everything the same way I did and I'm still having the same problem.
JS
$scope.play = function(id) {
soundcloud.stream(id).then(function(player) {
$scope.player = player;
player.play();
$scope.isPlaying = id;
});
$scope.isPlaying = id;
};
$scope.pause = function(id) {
$scope.player.pause();
$scope.isPlaying = false;
};
HTML
<ul ng-repeat="track in tracks">
<li>
<i class="fa fa-play" ng-show="isPlaying != track.id" ng-click="play(track.id)"></i>
<i class="fa fa-pause" ng-show="isPlaying = track.id" ng-click="pause(track .id)"></i>
<h4><a href="#" ng-bind="track.title"></a></h4>
</li>
</ul>