Fix event handling and emiting.

This commit is contained in:
Alexis Lahouze 2016-10-14 08:51:35 +02:00
parent 8ebe15f22f
commit bff2d826dc
2 changed files with 10 additions and 10 deletions

View File

@ -156,7 +156,7 @@ angular.module('accountant', [
vm.onAuthLoginRequired = $rootScope.$on('event:auth-loginRequired', vm.showLoginForm);
vm.$on('$destroy', function() {
$rootScope.$on('$destroy', function() {
vm.onAuthLoginRequired = angular.noop();
});
})

View File

@ -205,7 +205,7 @@ angular.module('accountant.operations', [
vm.getBalance(args.begin, args.end);
});
vm.$on('$destroy', function(){
$rootScope.$on('$destroy', function(){
vm.onRangeSelected = angular.noop();
});
}
@ -214,7 +214,7 @@ angular.module('accountant.operations', [
/*
* Controller for the sold chart.
*/
.controller('SoldChartController', function($rootScope, $http, OHLC) {
.controller('SoldChartController', function($rootScope, $scope, $http, OHLC) {
var vm = this;
// Configure chart for operations.
@ -285,7 +285,7 @@ angular.module('accountant.operations', [
minRange: 3600 * 1000 * 24 * 14, // 2 weeks
events: {
afterSetExtremes: function(e) {
vm.$emit('rangeSelectedEvent', {
$scope.$emit('rangeSelectedEvent', {
begin: moment.utc(e.min), end: moment.utc(e.max)
});
}
@ -320,7 +320,7 @@ angular.module('accountant.operations', [
]);
});
vm.$emit('rangeSelectedEvent', {
$scope.$emit('rangeSelectedEvent', {
begin: vm.config.xAxis.currentMin,
end: vm.config.xAxis.currentMax
});
@ -344,7 +344,7 @@ angular.module('accountant.operations', [
vm.config.yAxis.plotLines[1].value = account.authorized_overdraft;
});
vm.$on('$destroy', function() {
$rootScope.$on('$destroy', function() {
vm.onOperationSaved = angular.noop();
vm.onOperationDeleted = angular.noop();
vm.onAccountLoaded = angular.noop();
@ -357,7 +357,7 @@ angular.module('accountant.operations', [
/*
* Controller for the operations.
*/
.controller('OperationController', function($rootScope, $routeParams, $ngBootbox, Notification, Account, Operation) {
.controller('OperationController', function($rootScope, $scope, $routeParams, $ngBootbox, Notification, Account, Operation) {
var vm = this;
// List of operations.
@ -438,7 +438,7 @@ angular.module('accountant.operations', [
return operation.$save().then(function(data) {
Notification.success('Operation #' + data.id + ' saved.');
vm.$emit('operationSavedEvent', data);
$scope.$emit('operationSavedEvent', data);
});
};
@ -458,7 +458,7 @@ angular.module('accountant.operations', [
// Remove operation from array.
vm.operation.splice($index, 1);
vm.$emit('operationDeletedEvent', operation);
$scope.$emit('operationDeletedEvent', operation);
});
}
}
@ -476,7 +476,7 @@ angular.module('accountant.operations', [
vm.load(args.begin, args.end);
});
vm.$on('$destroy', function() {
$rootScope.$on('$destroy', function() {
vm.onRangeSelected = angular.noop;
});
})