Skip to content

Commit 5f83f52

Browse files
added addAll directive
1 parent 4fadfae commit 5f83f52

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
node_modules
2-
.DS_Store
2+
.DS_Store
3+
_pages
4+
_site

Gruntfile.js

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ module.exports = function (grunt) {
2929
'src/18-directive-playAll.js',
3030
'src/19-directive-volumeBar.js',
3131
'src/20-directive-playPauseToggle.js',
32+
'src/21-directive-addAll.js',
3233
],
3334
dest: 'dist/angular-soundmanager2.js'
3435
}

src/21-directive-addAll.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
ngSoundManager.directive('addAll', ['angularPlayer', '$log',
2+
function(angularPlayer, $log) {
3+
return {
4+
restrict: "EA",
5+
scope: {
6+
songs: '=playAll'
7+
},
8+
link: function(scope, element, attrs) {
9+
element.bind('click', function(event) {
10+
//first clear the playlist
11+
angularPlayer.clearPlaylist(function(data) {
12+
$log.debug('cleared, ok now add to playlist');
13+
//add songs to playlist
14+
for(var i = 0; i < scope.songs.length; i++) {
15+
angularPlayer.addTrack(scope.songs[i]);
16+
}
17+
});
18+
});
19+
}
20+
};
21+
}
22+
]);

0 commit comments

Comments
 (0)