Skip to content

Commit 25fb047

Browse files
committed
Directive toast
1 parent 1f12228 commit 25fb047

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/angular-materialize-toast.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
angular.module('ui.materialize.toast', [])
2+
3+
.constant('toastConfig', {
4+
duration: 3000,
5+
rounded : 'rounded'
6+
})
7+
8+
.directive('toast', ['toastConfig', function(toastConfig) {
9+
return {
10+
scope: {
11+
message: '@',
12+
},
13+
link: function (scope, element, attrs) {
14+
15+
element.bind(attrs.toast, function() {
16+
var message = (angular.isDefined(scope.message)) ? scope.message : '';
17+
var rounded = (angular.isDefined(attrs.rounded)) ? toastConfig.rounded : null;
18+
toast(message, toastConfig.duration, rounded);
19+
});
20+
}
21+
};
22+
}]);
23+

0 commit comments

Comments
 (0)