Skip to content

Instantly share code, notes, and snippets.

@tstpierre
Created March 29, 2016 16:19
Show Gist options
  • Save tstpierre/00a991f27fe32b831789 to your computer and use it in GitHub Desktop.
Save tstpierre/00a991f27fe32b831789 to your computer and use it in GitHub Desktop.
Barebones Angular 1 strong typed controller view model with TS
module app {
// Declare items explicitly the ng Controller will
// expose to the template html
export interface IMyViewModel {
firstName: string;
lastName: string;
getFullname(): string;
}
class MyAppController implements IMyViewModel {
firstName: string;
lastName: string;
getFullname = (): string => {
return this.firstName + ' ' + this.lastName;
}
}
angular
.module('myapp')
.controller('MyAppCtrl', MyAppController);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment