角度模态ng-click不起作用

时间:2016-07-03 16:12:13

标签: javascript angularjs

我已经制作了一个有角度的模态,它弹出很棒,但退出按钮不会触发关闭模态。如果重新点击要打开的按钮,但是在模态内添加新按钮不会触发该功能,则它可以工作。顺便说一句,这里没有引导程序。

var ar =  [{"STU":"Study1","SUB":"Subject1","EXL":"Yes"},{"STU":"Study1","SUB":"Subject1","EXL":"Yes"},{"STU":"Study2","SUB":"Subject1","EXL":"Yes"},{"STU":"Study3","SUB":"Subject1","EXL":"Yes"},{"STU":"Study1","SUB":"Subject1","EXL":"Yes"},{"STU":"Study3","SUB":"Subject1","EXL":"Yes"},{"STU":"Study3","SUB":"Subject1","EXL":"Yes"},{"STU":"Study2","SUB":"Subject1","EXL":"Yes"}]
var result = [];

ar.forEach(function(e) {
  if(!this[e.STU]) {
    this[e.STU] = {STU: e.STU, SUB : 0, EXL : e.EXL}
    result.push(this[e.STU]);
  }
  this[e.STU].SUB++;
}, {});

console.log(result)

1 个答案:

答案 0 :(得分:0)

用于隐藏弹出窗口的 $ scope.showMenu标志未正确使用。当$ scope.modalFunc方法被调用时,你否定$ scope.showMenu的值并分配。所以赋值后,$ scope.showMenu值将为true。 现在你使用了ng-show =" showMenu"所以你的弹出窗口不会被隐藏。

正确的代码将是:

1. Set $scope.showMenu = true in the callback which called when popup is opened.

2. $scope.modalFunc= function(){
   $scope.showMenu = !$scope.showMenu;
...
}

3. Remove $scope.showMenu=false; since it is not needed.