title: angularjs with typescript - cannot access $scope
body: <p>I am building an angularjs app using typescript, and have just created my first controller - the problem is that I'm having a hard time using <code>ng-model</code> with an object on it.</p>
  
  <p>This is what it all looks like;</p>
  
  <p><code>app.ts</code></p>
  
  <pre><code>((): void =&gt; {
     'use strict';
     angular.module('app', ['app.core','app.widgets','app.services']);
  })();
  </code></pre>
  
  <p><code>app.services.ts</code></p>
  
  <blockquote>
    <p>User Service is defined here and is not relevant to this sample</p>
  </blockquote>
  
  <p>'app.widgets.ts`</p>
  
  <pre><code>module app.widgets {
     'use strict';
     interface IUserController {
        User: app.services.IUser;
     }
  
     class UserController implements IUserController {
        User: app.services.IUser;
  
        static $inject = ['$scope', 'app.services.UserService'];
        constructor(scope: any, userService: app.services.IUserService){
           var vm = this;
           userService.Find().then((user: app.services.IUser): void =&gt; {
              scope.User = user; // this is the offending line
           });
        }
     }
  
     angular.module('app.widgets').controller('app.widgets.UserController', UserController);
  }
  </code></pre>
  
  <p>I attempt to call this in my HTML like this;</p>
  
  <pre><code>&lt;body ng-app="app" ng-controller="app.widgets.UserController"&gt;
     {{ User.UserName }}
  &lt;/body&gt;
  </code></pre>
  
  <p>Or ..</p>
  
  <pre><code>&lt;h1 ng-model="User.UserName"&gt;&lt;/h1&gt;
  </code></pre>
  
  <h1>Update</h1>
  
  <p>I haven't quite solved it completely, but I have made more progress </p>
  
  <pre><code>interface IUserControllerScope extends angular.IScope {
     User: app.services.IUser;
  }
  
  class UserController {
      static $inject = ['$scope', 'app.services.UserService'];
      constructor($scope: IUserControllerScope, userService: app.services.IUserService) {
         var _this = $scope;
         userService.Find().then((user: app.services.IUser): void =&gt; {
               _this.User = user;
            });
         }
      }
  }
  </code></pre>