(function(){ 'use strict'; app.controller('Reply', ['$rootScope', '$scope', function($rootScope,$scope){ $scope.comment = {authorName: '', foto: '', commentText: '', isEditMod: false, isReplyMod: false, secondComments: [] }; $rootScope.$on('Reply', function(evnt, commets, id){ $scope.comment.id = new Date().getTime() return $scope.comment.mainId = id }); $scope.replyComment = function(){ $rootScope.$emit('commentReply', $scope.comment, $scope.comment.mainId); return $scope.comment = {authorName: '', foto: '', commentText: '', isEditMod: false, isReplyMod: false, secondComments: [] }; } $scope.replyCancel = function(){ $rootScope.$emit('cancelReplyMod',$scope.comment.mainId) } }]) })()