title: Re-Usable Angularjs Code
body: <p>I have scope function ClickA and ClickB in my controller CtrlA, I want to re-use ClickA and ClickB with there containing scope variables "a" and "b" in almost every other controllers, I mean, I simply want to make available these click functions and its containing variables to other controllers without redefining them. It may be possible with services/factory but have no idea to work with them or its directory don't know, can someone suggest me with an example please and yes after injecting/calling these code they should become part of $scope variable for the respective controller.</p>
  
  <pre class="lang-js prettyprint-override"><code>angular.module("App").controller("CtrlA", function($scope)
  {
  
  $scope.ClickA = function(){
  
  $scope.a =true;
  $scope.b = false;
  }
  
  
  $scope.ClickB = function(){
  
  $scope.a =false;
  $scope.b = true;
  }
  
  });
  </code></pre>
  
  
  
  <pre><code>&lt;button ng-click="ClickA()"/&gt;
  {{a}}&lt;br&gt;
  {{b}}
  
  &lt;button ng-click="ClickB()"/&gt;
  {{a}}&lt;br&gt;
  {{b}}
  </code></pre>