change rootScope.broadcast to scope.emit