Javascript 角度UI引导警报未关闭
我已经复制了angular UI示例,但它并没有关闭。 尽管我的关闭函数正在被调用,etc也尝试手动将警报设置为null,但没有运气 HTML: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
试着这样,它起作用了
<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);
};