After much messing around …
yarn add toastr
yard add @types/toastr
viewmodel.ts
import * as toastr from "toastr"
import "../../../node_modules/toastr/build/toastr.min.css";
public bind(){
toastr.options.closeButton = true // etc
}
// statusMessage just holds the status and message you wish to display
public setNotification() {
switch (this.statusMessage.status) {
case StatusType.error:
toastr.error(this.statusMessage.message);
break;
case StatusType.info:
toastr.info(this.statusMessage.message);
break;
case StatusType.ok:
toastr.success(this.statusMessage.message);
break;
default:
toastr.clear();
}
}
viewmodel.html
<div if.bind="statusMessage.show">
${setNotification()}
</div>
Hope it helps someone