forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangularjs-toaster-tests.ts
42 lines (38 loc) · 1.54 KB
/
angularjs-toaster-tests.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/// <reference path="angularjs-toaster.d.ts" />
class NgToasterTestController {
constructor(public $scope: ng.IScope, public $window: ng.IWindowService, public toaster: ngtoaster.IToasterService) {
this.bar = 'Hi';
}
bar: string;
pop(): void {
this.toaster.success({ title: "title", body: "text1" });
this.toaster.error("title", "text2");
this.toaster.pop({ type: 'wait', title: "title", body: "text" });
this.toaster.pop('success', "title", '<ul><li>Render html</li></ul>', 5000, 'trustedHtml');
this.toaster.pop('error', "title", '<ul><li>Render html</li></ul>', null, 'trustedHtml');
this.toaster.pop('wait', "title", null, null, 'template');
this.toaster.pop('warning', "title", "myTemplate.html", null, 'template');
this.toaster.pop('note', "title", "text");
this.toaster.pop('success', "title", 'Its address is https://google.com.', 5000, 'trustedHtml', (toaster: ngtoaster.IToast): boolean => {
var match = toaster.body.match(/http[s]?:\/\/[^\s]+/);
if (match) {
this.$window.open(match[0]);
}
return true;
});
this.toaster.pop('warning', "Hi ", "{template: 'myTemplateWithData.html', data: 'MyData'}", 15000, 'templateWithData');
}
goToLink(toaster: ngtoaster.IToast): boolean {
var match = toaster.body.match(/http[s]?:\/\/[^\s]+/);
if (match) {
this.$window.open(match[0]);
}
return true;
}
clear(): void {
this.toaster.clear();
}
}
angular
.module('main', ['ngAnimate', 'toaster'])
.controller('myController', NgToasterTestController);