What's the correct way to communicate between controllers in AngularJS?

前端 未结 19 2459
猫巷女王i
猫巷女王i 2020-11-21 22:02

What\'s the correct way to communicate between controllers?

I\'m currently using a horrible fudge involving window:

function StockSubgro         


        
19条回答
  •  北恋
    北恋 (楼主)
    2020-11-21 22:54

    You can access this hello function anywhere in the module

    Controller one

     $scope.save = function() {
        $scope.hello();
      }
    

    second controller

      $rootScope.hello = function() {
        console.log('hello');
      }
    

    More info here

提交回复
热议问题