I have a controller as below, with an .$on
attribute that is called via .$broadcast
when a form is submitted. I'd also like the event to run when the controller loads. Is there a syntactically easy way to go about doing this, or will I have to add a on page load
listener?
myApp.controller('DownloadsCloudCtrl', ['$scope',
'$rootScope',
'requestService',
function($scope, $rootScope, requestService){
$scope.title = 'Most Popular Keywords';
$scope.tooltip = 'Test tooltip';
$rootScope.$on('updateDashboard', function(event, month, year) {
requestService.getP2PKeywordData(month, year).then(function(data) {
$scope.d3Data = data;
});
});
}]);