title: AngularJS and Typescript with app.js
body: <p>I have a simple application using Typescript and angular JS. I use the app.js to register my controller and some route parameters:</p>
  
  <pre><code>/// &lt;reference path="../scripts/typings/angularjs/angular.d.ts" /&gt;
  /// &lt;reference path="secondController.ts" /&gt;
  /// &lt;reference path="../scripts/typings/angularjs/angular-route.d.ts" /&gt;
  module myApp {
  export class Config {
    constructor($routeProvider: ng.route.IRouteProvider) {
       $routeProvider.when("/add", { templateUrl: "test.html", controller: "CategoryCtrl" })
          .when("/add2", { templateUrl: "test.html", controller: "secondController" })
          .otherwise({ redirectTo: '/list' });
    }
  }
  Config.$inject = ['$routeProvider'];
  export class CategoryCtrl {
    constructor($window) {
       $window.alert("Hi from CategoryCtrl");
    }
  }
  CategoryCtrl.$inject = ['$window'];
  var app = angular.module("myApp", ['ngRoute']);
  app.config(Config);
  app.controller('CategoryCtrl', CategoryCtrl);
  app.controller('secondController', secondController);
  }
  </code></pre>
  
  <p>This works fine. Here some snipped, how I use the code:</p>
  
  <pre><code>div class="container" style="margin-top:10px;"&gt;
       &lt;div class="col-md-3" ng-controller="CategoryCtrl"&gt;
          &lt;a href="#/add" style="color:blue; font-weight:bold;"&gt;Add New Video&lt;/a&gt;&lt;br /&gt;
          &lt;a href="#/add2" style="color:blue; font-weight:bold;"&gt;Add New Video2&lt;/a&gt;
       &lt;/div&gt;
  </code></pre>
  
  <p>So far, so good.
  I have another file, called "secondController.ts", which looks like:</p>
  
  <pre><code>module myApp {
  export class secondController {
    constructor($window) {
       $window.alert("Second Controller");
    }
  }
  secondController.$inject = ['$window'];
  }
  </code></pre>
  
  <p>As You can see, I already registered this controller in my app.js (app.ts), but if I change the "ng-controller='CategoryCtrl'" to "ng-controller='secondController'" this doesn't work.
  If I just copy the code from the secondController.ts-file to my app.ts, there is no problem.... I don't see the error and I would be grateful for any help.</p>