Created
September 9, 2015 12:56
-
-
Save kis/b1e78bd116417e189150 to your computer and use it in GitHub Desktop.
modal instance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$scope.openModal = function(video) { | |
var modalInstance = addVideoService.openAddVideoModal(video); | |
return modalInstance.result; | |
}; | |
$scope.addVideo = function() { | |
$scope.openModal(null).then(function(data) { | |
data.date_created = new Date(); | |
$scope.profile.videos.unshift(data); | |
}); | |
}; | |
$scope.editVideo = function(video_id, title, url) { | |
event.stopPropagation(); | |
var video = {title: title, url: url}; | |
$scope.openModal(video).then(function(data) { | |
$scope.profile.videos.forEach(function(video, index, arr) { | |
if (video.video_id == video_id) { | |
if (data.remove) { | |
arr.splice(index, 1); | |
} else { | |
arr[index].title = data.title; | |
arr[index].url = data.url; | |
} | |
} | |
}); | |
}); | |
}; | |
$scope.removeVideo = function(video_id) { | |
event.stopPropagation(); | |
if (confirm('Delete video?')) { | |
$scope.profile.videos.forEach(function(video, index, arr) { | |
if (video.video_id == video_id) { | |
arr.splice(index, 1); | |
} | |
}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment