title: TypeScript Angular function on service is not defined or undefined
body: <p>Here is my service.</p>
  
  <pre><code>export module cropyear_services {
  //export interface ICropYearService {
  //    getFieldYearData(): any;
  
  //}
  export class CropYearService {    
  
      static $inject: string[] = ["$q", "$filter", "$httpBackend", "$http"];
      constructor(private _q: ng.IQService, private _http: ng.IHttpService, private _filter: ng.IFilterService, private _$httpMock: ng.IHttpBackendService) { }
  
      getFieldYearData = function () {
  
          let deferred = this._q.defer();
          let uri = endpoints.Endpoints.endpoints.fieldyears;
          this._http.get(uri).then((fieldYearResultData: any) =&gt; {
              let fieldYearData = fieldYearResultData.data[0].ResultSet;
              deferred.resolve({ result: fieldYearData });
          }).catch(() =&gt; {
              deferred.reject();
          });         
  
          return deferred.promise;
      }
  
   }
  }
  </code></pre>
  
  <p>And Here is my controller where I am calling the service method.</p>
  
  <pre><code>/// &lt;reference path="../../../../thirdparty/lodash/lodash.d.ts"/&gt;
  /// &lt;reference path="../../../../thirdparty/angular-material/angular-material.d.ts"/&gt;
   /// &lt;reference path="../../../../thirdparty/angular/angular.d.ts"/&gt;
  /// &lt;reference path="../../../../thirdparty/angular-ui-router/api/angular-ui-router.d.ts"/&gt;
  /// reference path="./cropyear.service.ts"/&gt;
  /// reference path= "../../../../common/sharedData/TSModule/sharedData.ts'/&gt;
  import service = require('./cropyear.service');
  import SharedDataFactory =    require('../../common/sharedData/TSModule/sharedData'); 
  
  export module cropyear_controllers {
  export class CropYearController {
      static $inject: string[] = ["$log", "$scope", "cropYearService"];
      constructor(/*private _log: ng.ILogService,*/ public _scope: ng.IScope,   public _cropYearService:  service.cropyear_services.CropYearService
          , public _sharedData: any, public fieldYears: any) {
          this._sharedData = SharedDataFactory.sharedData_factories.SharedData;
      }
      loadYears() {            
          this._cropYearService.getFieldYearData()
              .then((data: any) =&gt; {
                  this.fieldYears = _.uniq(_.pluck(data.result, 'CropYear'));
              })
              .catch(() =&gt; {
                  console.log('Error calling farm view  service');
              });
      }
      hangeCropYear(year: number) {
          this._sharedData.selectCropYear(year);
      }
  }
  }
  </code></pre>
  
  <p>Vs compiles it with no errors. When I try to rise the loadYears(), i get error in console that Uncaught TypeError: this._cropYearService.getFieldYearData is not a function. Can any one point out where is my mistake? </p>