title: TypeScript + JavaScript: Is not a function at x?
body: <p>I am new to TypeScript and I'm running into a bug within my AngularJS + TypeScript/JavaScript app.</p>
  
  <p>I have a service that looks a little like this:</p>
  
  <pre><code>module myApp {
  
      'use strict';
  
      export interface IActionItem {
          name: String;
          link?: String;
          icon: String;
          action?: any;
          className: String;
          order: Number;
      }
  
      export interface IActionItemsService {
          getActionItems() : IActionItem[];
      }
  
      class ActionItemsService implements IActionItemsService {
  
          private activeActionItemClass:String = 'active_menu_item';
          private actionItems:IActionItem[] = [
              {
                  name: 'Search',
                  icon: 'magnifier',
                  action: this.search,
                  className: 'visible',
                  order: 2
              }
          ];
  
          constructor() {
  
          }
  
          private search(actionItem:IActionItem) {
  
              this.toggleActiveClass(actionItem);
  
          }
  
          private toggleActiveClass(actionItem:IActionItem) {
              // do some stuff with the actionItem className
          }
  
      }
  }
  </code></pre>
  
  <p>...A controller that handles setting an array of action items to the scope.
  And just a simple HTML page that handles a click action:</p>
  
  <pre><code>&lt;div class="list_menu_options" ng-repeat="actionItem in vm.actionItems | orderBy:'order':true "&gt;
  
      &lt;a ng-class="actionItem.className"
              ng-click="actionItem.action(actionItem)"&gt;
          &lt;span class="icon-{{actionItem.icon}}"&gt;&lt;/span&gt;
          {{ actionItem.name }}
      &lt;/a&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>Everything seems to be working as expected (and TypeScript compiles to JavaScript without error), but when I click on my search item, I see:</p>
  
  <pre><code>TypeError: this.toggleActiveClass is not a function
  at Object.ActionItemsService.search [as action]
  </code></pre>
  
  <p>I'm sure I'm misusing something somewhere due to a minimal understanding of TypeScript, but I can't seem to find it. Any suggestions?</p>