title: How to initialize the controller $scope variables in angularJS
body: <p>I have one view where I am accessing scope variables from on angular controller function.</p>
  
  <pre><code>$scope.getCurrentTab = function (tab) {
   $scope.yourReportEnabled = (tab === 'REPORTS');
   $scope.currentTab = tab;
  }
  </code></pre>
  
  <p>in the view I have two anchors on click of which I call <code>getCurrentTab()</code> by passing the tab name as a parameter.</p>
  
  <p>Here the scope are variables defined in the function getCurrentTab which will be initialized only on the function call.</p>
  
  <p>But if I define these variables outside the function these <code>gets initialized multiple times</code>.</p>
  
  <p>So is there a way to define the scope <code>variables only once</code> which will be modified by <code>getCurrentTab</code> function only.</p>
  
  <p>Thanks in advance! </p>