editSecond.controller.js 1.1 KB

123456789101112131415161718192021222324252627
  1. (function(){
  2. 'use srict';
  3. app.controller('EditSecond', ['$rootScope', '$scope', function($rootScope, $scope){
  4. $rootScope.$on('EditSecondComment', function(event, comments, mainId, secondId){
  5. for (let i = 0; i < comments.length; i++) {
  6. for (let j = 0; j < comments[i].secondComments.length; j++) {
  7. if (comments[i].secondComments[j].mainId === mainId) {
  8. if (comments[i].secondComments[j].id === secondId) {
  9. $scope.editSecondCommetById = comments[i].secondComments[j]
  10. }
  11. }
  12. }
  13. }
  14. });
  15. $scope.saveSecondEdit = function(){
  16. $rootScope.$emit('SaveSecondEdit', $scope.editSecondCommetById, $scope.editSecondCommetById.mainId, $scope.editSecondCommetById.id);
  17. };
  18. $scope.cancelSecondEdit = function(){
  19. $rootScope.$emit('CancelSecondEdit', $scope.editSecondCommetById.mainId, $scope.editSecondCommetById.id);
  20. };
  21. }])
  22. })()