title: How to inject factory to controller?
body: <p>Hi I am new to angularjs and I am trying to inject some factory to controller but I am facing difficulties. My factory works fine. I am able to set data in factory. </p>
  
  <p>Below is my code where I inject factory.</p>
  
  <pre><code>function () {
      angular.module('RoslpApp').controller('RegistrationOTPVerification', ['$scope', '$http', '$translatePartialLoader', '$translate', '$state', '$stateParams', 'SomeFactory',
          function ($scope, $http, $translatePartialLoader, $translate, $state, $stateParams, CONSTANTS, SomeFactory) {
  
          var OTP = $stateParams.pageList.OTP;
          $scope.EnterOTP = "Please enter this OTP to verify the user " + OTP;
        //RegistrationOTPVerification.$inject = ['SomeFactory'];
        //Facing issues in above line
          alert(1);
          function RegistrationOTPVerification(SomeFactory) {
              var vm = this;
              vm.someVariable = SomeFactory.getData();
              console.log(vm.someVariable);  // logs your data
              alert(vm.someVariable);
          }
  });
  </code></pre>
  
  <p>This is my factory code.</p>
  
  <pre><code>(function () {
      'use strict';
      angular
        .module('RoslpApp')
        .factory('SomeFactory', SomeFactory);
  
      SomeFactory.$inject = [];
  
      function SomeFactory() {
          var someData;
  
          var factory = {
              setData: setData,
              getData: getData
          };
          function setData(data) {
  
              someData = data;
          }
  
          function getData() {
              return someData;
          }
  
          return factory;
      }
  })();
  </code></pre>
  
  <p>I set data in some other controller with <code>SomeFactory.setData("123")</code></p>
  
  <p>I want to inject <code>someFactory</code> as below:</p>
  
  <p><code>RegistrationOTPVerification.$inject = ['SomeFactory'];</code> </p>
  
  <p>But whenever I write this, I get error <code>RegistrationOTPVerification</code> is <code>undefined</code>. If I comment that line everything works fine but I want to get some data from factory.</p>
  
  <p>My factory name is <code>SomeFactory</code> and I want to inject in above controller. Any help would be appreciated.</p>