我有以下代码来创建角度材料吐司。单击关闭按钮时,我遇到了奇怪的问题。当我点击关闭按钮时,它会关闭框架,即。得到文本的范围被关闭然后主要关闭。不知道我做错了什么。
我的代码:
<md-toast ng-if="messageState.getNoRecordsMessage()" class="toast-container toast-success">
<span class="md-toast-text" flex>{{messageState.getNoRecordsMessage()}}</span>
<md-button ng-click="closeToast()">
<md-icon md-svg-icon="close" class="white-font"></md-icon>
</md-button>
</md-toast>
<md-toast ng-if="messageState.getErrorMessage()" class="toast-container toast-error">
<span flex> {{messageState.getErrorMessage()}} <br> Please contact your system administrator if the error persists. </span>
<md-button ng-click="closeToast()" class="white-font">
<md-icon md-svg-icon="close"></md-icon>
</md-button>
</md-toast>
<md-toast ng-if="messageState.getSuccessMessage()" class="toast-container toast-success">
<span flex>{{messageState.getSuccessMessage()}}</span>
<md-button ng-click="closeToast()">
<md-icon md-svg-icon="close" class="white-font"></md-icon>
</md-button>
</md-toast>
关闭功能是:
$scope.closeToast = function () {
$mdToast
.hide()
.then(function () {
$scope.messageState.setSuccessMessage("");
})
}
有人能弄清楚我在这里做错了什么吗?
由于
答案 0 :(得分:0)
也许这可以从documentation page获得帮助,如果对话框已打开则需要额外检查,不确定是否是您的问题。
$scope.closeToast = function() {
if (isDlgOpen) return;
$mdToast
.hide()
.then(function() {
isDlgOpen = false;
$scope.messageState.setSuccessMessage("");
});
};