Advertisement
Guest User

Untitled

a guest
Jun 30th, 2015
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. $scope.SaveDB(iObj,function(iResult){
  2. //after a sucessfull opreation in the DB. Now I need iObj to pass to other controller.
  3. // I have used $emit method
  4. $rootScope.$emit('saveCallback');
  5. })
  6.  
  7. var _save = $rootScope.$on('saveCallback',function(){
  8. //i want same obj(which is used for saving ) to be access here.
  9. })
  10.  
  11. $scope.SaveDB(iObj,function(iResult){
  12. $scope.$emit('saveCallback',iResult); //pass the data as the second parameter
  13. });
  14.  
  15. $scope.$on('saveCallback',function(event,iResult){//receive the data as second parameter
  16.  
  17. });
  18.  
  19. $scope.SaveDB(iObj,function(iResult){
  20.  
  21. $scope.$emit('saveCallback',iResult);
  22. });
  23.  
  24. $scope.$on('saveCallback',function (event,iresult){
  25. $scope.$broadcast('saveCallback',iresult);
  26. });
  27.  
  28. $scope.SaveDB(iObj,function(iResult){
  29. $rootScope.$broadcast('saveCallback',iResult);
  30. });
  31.  
  32. $scope.$on('saveCallBack',function(event, data) {
  33. //access data here
  34. });
  35.  
  36. $rootScope.$broadcast('saveCallback',iresult);
  37.  
  38. $scope.$on('saveCallBack',function(event, data) {
  39. //access data here
  40. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement