While using $mdToast.simple().content(\"some test\")
it is showing the toast with black color. how can I change that color to red, yellow and so, depends on the typ
You can do it with factory and some css.
(function () {
'use strict';
angular
.module('app.core')
.factory('ToastService', ToastService);
/** @ngInject */
function ToastService($mdToast) {
var service = {
error: error,
success: success,
info : info
};
return service;
//////////
function success(text) {
$mdToast.show(
$mdToast.simple()
.toastClass("toast-success")
.textContent(text)
);
}
function info(text) {
$mdToast.show(
$mdToast.simple()
.toastClass("toast-info")
.textContent(text)
);
}
function error(text) {
$mdToast.show(
$mdToast.simple()
.toastClass("toast-error")
.textContent(text)
);
}
}
}());
And css.
.toast-error .md-toast-content{
background-color: rgb(102,187,106) !important;
}
.toast-info .md-toast-content{
background-color: rgb(41,182,246) !important;
}
.toast-error .md-toast-content{
background-color: rgb(239,83,80) !important;
}