Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/394.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 角度UI引导警报未关闭_Javascript_Angularjs_Angular Ui Bootstrap - Fatal编程技术网

Javascript 角度UI引导警报未关闭

Javascript 角度UI引导警报未关闭,javascript,angularjs,angular-ui-bootstrap,Javascript,Angularjs,Angular Ui Bootstrap,我已经复制了angular UI示例,但它并没有关闭。 尽管我的关闭函数正在被调用,etc也尝试手动将警报设置为null,但没有运气 HTML: 试着这样,它起作用了 <alert ng-repeat="alert in cantVoteWhenNotLoggedInAlerts" type="alert.type" ng-click="closeCantVoteWhenNotLoggedInAlert(this)">{{ alert.msg }}</alert&g

我已经复制了angular UI示例,但它并没有关闭。 尽管我的关闭函数正在被调用,etc也尝试手动将警报设置为null,但没有运气

HTML:


试着这样,它起作用了

<alert ng-repeat="alert in cantVoteWhenNotLoggedInAlerts" type="alert.type"
      ng-click="closeCantVoteWhenNotLoggedInAlert(this)">{{ alert.msg }}</alert>


$scope.closeCantVoteWhenNotLoggedInAlert = function (this) {
            $scope.cantVoteWhenNotLoggedInAlerts.splice(this.$index, 1);
        };
{{alert.msg}
$scope.closeCantVoteWhenNotLoggedInAlert=函数(此){
$scope.cantVoteWhenNotLoggedInAlerts.splice(此.$index,1);
};

看起来没问题,你能发布一个JSFIDLE吗?你的代码可以工作。这是Js小提琴。不适合我,反正不应该将“this”作为参数传入?也许是因为我的警报已经在一个很短的时间内了
//add
$scope.cantVoteWhenNotLoggedInAlerts.push({
  type: 'warning',
  msg: 'Must be logged in'
});                                

$scope.closeCantVoteWhenNotLoggedInAlert = function (index) {
  $scope.cantVoteWhenNotLoggedInAlerts.splice(index, 1);
};
<alert ng-repeat="alert in cantVoteWhenNotLoggedInAlerts" type="alert.type"
      ng-click="closeCantVoteWhenNotLoggedInAlert(this)">{{ alert.msg }}</alert>


$scope.closeCantVoteWhenNotLoggedInAlert = function (this) {
            $scope.cantVoteWhenNotLoggedInAlerts.splice(this.$index, 1);
        };