title: Defining a controller - angularjs
body: <p>I am doing it this way.</p>
  
  <p><strong>Method 1:</strong></p>
  
  <pre><code>var app = angular.module('MyModule', ['ngDialog']);
  app.controller('MyController', function ($scope,ngDialog) {
  ///
  });
  </code></pre>
  
  <p>but i see a lot like the below kind in articles</p>
  
  <p><strong>Method 2:</strong></p>
  
  <pre><code>app.controller('MyController', ['$scope', function ($scope) {
  ///
  }]);
  </code></pre>
  
  <p>Please help me understand why is $scope mentioned twice in method 2. 
  Is method 1, a good practice. If not, in what cases will it fail.</p>