Javascript AngularJS烤面包机烤面包机容器中的烤面包机数量
我用过,看起来很棒。正在搜索堆栈,但未找到以下内容: 我如何在控制器中的烤面包机容器中存储打开的烤面包机的数量Javascript AngularJS烤面包机烤面包机容器中的烤面包机数量,javascript,angularjs,Javascript,Angularjs,我用过,看起来很棒。正在搜索堆栈,但未找到以下内容: 我如何在控制器中的烤面包机容器中存储打开的烤面包机的数量 angular.module('main', ['toaster', 'ngAnimate']) .controller('myController', function($scope, toaster) { $scope.pop = function(){ toaster.pop('info', "title", "text"); }; $sc
angular.module('main', ['toaster', 'ngAnimate'])
.controller('myController', function($scope, toaster) {
$scope.pop = function(){
toaster.pop('info', "title", "text");
};
$scope.toastCount = function(){
//solution goes here
}
});
在html中:
<toaster-container></toaster-container>
上面的代码在某种程度上是伪代码,所以您应该熟悉Angular toaster来回答这个问题。
非常感谢您的帮助 您可以使用Angularjs toaster的onShowCallback和onHideCallback获取当前打开的toaster计数,如下所示:
app.controller('myController', function($scope, toaster, $window) {
$scope.count = 0
$scope.pop = function() {
toaster.pop({
type: 'success',
title: 'Success',
body: 'This will work !',
onHideCallback: function() {
$scope.count--;
},
onShowCallback: function() {
$scope.count++;
}
});
};
});
正如您在onShowCallback上看到的,我增加了计数,在onHideCallback上,我减少了计数,以获得当前打开的烤面包机计数
这里还有一个工作示例:
您需要所有打开的祝酒计数或当前打开的祝酒计数。还有,为什么你想得到你的开放式祝酒计数。我想要当前开放式祝酒。我需要它在程序的某个地方。如果没有开放式祝酒,我想隐藏一个按钮。嗨,阿里,我已经发布了我的答案。这对你有用吗?