Created
March 29, 2016 16:19
-
-
Save tstpierre/00a991f27fe32b831789 to your computer and use it in GitHub Desktop.
Barebones Angular 1 strong typed controller view model with TS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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