I created this small sample that shows how to write a Durandal ViewModel using TypeScript:
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
/// <reference path="../../../Scripts/typings/knockout/knockout.d.ts" /> | |
/// <reference path="../../../Scripts/typings/durandal/durandal-1.x.d.ts" /> | |
import system = require('durandal/system'); | |
class createUserViewModel{ | |
public user = { | |
LastName: ko.observable(''), | |
FirstName:ko.observable('') | |
}; | |
public activate=function() { | |
system.log('screen activated'); | |
alert('screen activated'); | |
}; | |
public create = () => { | |
alert('new user created:' + this.user.LastName() + ' ' + this.user.FirstName()); | |
}; | |
} | |
export =createUserViewModel; | |