mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-03-11 09:51:23 +00:00
56 lines
1.2 KiB
JavaScript
56 lines
1.2 KiB
JavaScript
|
|
angular.module('toastDemo1', ['ngMaterial'])
|
|
|
|
.controller('AppCtrl', function($scope, $mdToast, $animate) {
|
|
|
|
$scope.toastPosition = {
|
|
bottom: false,
|
|
top: true,
|
|
left: false,
|
|
right: true
|
|
};
|
|
|
|
$scope.getToastPosition = function() {
|
|
return Object.keys($scope.toastPosition)
|
|
.filter(function(pos) { return $scope.toastPosition[pos]; })
|
|
.join(' ');
|
|
};
|
|
|
|
$scope.showCustomToast = function() {
|
|
$mdToast.show({
|
|
controller: 'ToastCtrl',
|
|
templateUrl: 'toast-template.html',
|
|
hideDelay: 6000,
|
|
position: $scope.getToastPosition()
|
|
});
|
|
};
|
|
|
|
$scope.showSimpleToast = function() {
|
|
$mdToast.show(
|
|
$mdToast.simple()
|
|
.content('Simple Toast!')
|
|
.position($scope.getToastPosition())
|
|
.hideDelay(0)
|
|
);
|
|
};
|
|
|
|
$scope.showActionToast = function() {
|
|
var toast = $mdToast.simple()
|
|
.content('Action Toast!')
|
|
.action('OK')
|
|
.highlightAction(false)
|
|
.position($scope.getToastPosition());
|
|
|
|
$mdToast.show(toast).then(function() {
|
|
alert('You clicked \'OK\'.');
|
|
});
|
|
};
|
|
|
|
})
|
|
|
|
.controller('ToastCtrl', function($scope, $mdToast) {
|
|
$scope.closeToast = function() {
|
|
$mdToast.hide();
|
|
};
|
|
});
|