app.controller('testCtrl', function ($rootScope, $scope, $mdToast)
{
$scope.showHideToast = function () {
$mdToast.show({
template: '<md-toast>test</md-toast>',
hideDelay: 0,
position: 'bottom right'
});
// DO STUFF
$mdToast.hide();
}
吐司出现但没有隐藏。
我得到这个类型错误:
TypeError: undefined is not a function
at Object.onRemove (../angular-material/angular-material.js:4240:13)
at Object.InterimElement.self.remove (../angular-material/angular-material.js:5103:29)
at Object.hide (../angular-material/angular-material.js:5032:40)
...
为什么这在 Angular Material 中不起作用?
有办法让这个工作吗?
真正的问题是你如何使用hide
方法,它可以选择在输入中接收要解决的承诺。
所以你的代码为了工作应该是:
app.controller('testCtrl', function ($rootScope, $scope, $mdToast)
{
$scope.showHideToast = function () {
// hold the reference
var myToast = $mdToast.show({
template : '<md-toast>test</md-toast>',
hideDelay : 0,
position : 'bottom right'
});
// DO STUFF
// hide the toast
$mdToast.hide(myToast);
};
}
呼叫hide
以这种方式关闭先前定义的 toast 方法,即使它是用hideDelay: 0
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)