i am new to Typescript and want to display a Angular Material Dialog with typescript but i am not able to configure the Controller because typescript says "content" does not exist. Which is right but how do i say Typescript that it exists?
Here is my Code:
interface IToastService {
displayError(text: string): void;
displaySuccess(text: string): void;
}
export class ToastService implements IToastService {
public static $inject = ['$mdToast'];
constructor(
private $mdToast: angular.material.IToastService) { }
displayError(text: string): void {
this.$mdToast.show({
position: 'top left',
controller: () => {
this.content = text; // the Error Line
},
controllerAs: 'toast',
template: '<md-toast>\
{{ toast.content }}\
<md-button ng-click="toast.cancel()" class="md-warn">\
<md-icon md-font-set="material-icons"> clear </md-icon>\
</md-button>\
</md-toast>',
hideDelay: 0
});
}
displaySuccess(text: string): void {
this.$mdToast.show({
template: '<md-toast>\
{{ toast.content }}\
<md-icon md-font-set="material-icons" style="color:#259b24"> done </md-icon>\
</md-toast>',
hideDelay: 1000,
position: 'top left',
controller: () => {
this.content = text;
},
controllerAs: 'toast'
})
}
}