edit.controller.js 683 B

123456789101112131415161718192021
  1. (function(){
  2. 'use strict';
  3. app.controller('Edit',['$scope','$rootScope', function($scope, $rootScope){
  4. $rootScope.$on('EditComment', function(evnt, comments, id){
  5. for (let i = 0; i < comments.length; i++) {
  6. if(comments[i].id === id){
  7. $scope.editCommetById = comments[i]
  8. }
  9. }
  10. })
  11. $scope.saveEdit = function(){
  12. $rootScope.$emit('saveEdit', $scope.editCommetById, $scope.editCommetById.id);
  13. }
  14. $scope.cancelEdit = function(){
  15. $rootScope.$emit('cancelEdit', $scope.editCommetById.id);
  16. }
  17. }])
  18. })()