问题描述
在使用 $ mdToast.simple()。内容(有些测试)
是表示用黑色的烤面包。我怎样才能改变这种颜色为红色,黄色等,依赖于像错误,警告和成功的错误消息的类型。
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 type of the error messages like error, warning and success.
推荐答案
编辑:结果
对于正确执行,请使用的:在!)
过时:结果
我曾与显示解决方案jhblacklocks自定义文本的问题,所以我决定做这样使用模板:
OUTDATED:
I had problems displaying custom text with jhblacklocks solution, so I decided to do it like this using 'template':
var displayToast = function(type, msg) {
$mdToast.show({
template: '<md-toast class="md-toast ' + type +'">' + msg + '</md-toast>',
hideDelay: 6000,
position: 'bottom right'
});
};
我也在我的.css文件添加不同的类型:
I also added the different types in my .css file:
.md-toast.error {
background-color: red;
}
.md-toast.success {
background-color: green;
}
不知道这是最美丽的方法,但我并不需要一个模板文件每个对话框类型和显示自定义文本是很容易的。
Don't know if this is the most beautiful approach, but I don't need a template files for each dialog type and displaying custom text is really easy.
这篇关于我怎么可以改变面包的颜色取决于消息类型的角料$ mdToast?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!