我正在尝试在使用角度材质库的角度应用中实现Toast消息。
app.service('ToastFlash', ['$mdToast', function($mdToast) { this.showMessage = function(message, $event) { $mdToast.show( $mdToast .simple() .textContent(message) .action("Dismiss") .highlightAction(true) .highlightClass('md-accent') ); }; }]);
出于某种原因,当我致电showMessage()
时,这会给我一个错误:
TypeError: $mdToast.simple(...).textContent(...).action(...).highlightAction(...).highlightClass is not a function
。
当我删除highlightClass线时,它完美地工作。
为什么会这样?
答案 0 :(得分:2)
它应该使用最新的材料版本v1.1.0-rc.5
js和css文件,
$scope.showToast = function() {
var toast = $mdToast.simple()
.content('Hello world')
.action('OK')
.highlightAction(true)
.position('left top right')
.highlightClass('md-warn');
$mdToast.show(toast);
};
这是工作JsFiddle