DamianEdwards / grunt-tsng

A TypeScript pre-processor for AngularJS
Apache License 2.0
29 stars 3 forks source link

Consider registering controllers using the interface they implement as the name #4

Open DamianEdwards opened 10 years ago

DamianEdwards commented 10 years ago

Might make more sense to register controllers using the interface they implement (if any) instead of the class name. Means that HTML views would refer to them by the interface name, e.g.

module MyApp {
    interface IHelloViewModel {
        message: string;
    }

    class HelloController implements IHelloViewModel {
        constructor() {
            this.message = "Hello";
        }

        public message: string;
    }
}
<div ng-controller="MyApp.IHelloViewModel as vm">
   {{ vm.message }}
</div>