Angular UT Bootstrap Warning Doesn't Close

I copied the angular Uis example and did not close. Despite the fact that my closing function is called, etc., And also tried to set the warning to zero manually and no luck.

HTML:

<alert ng-repeat="alert in cantVoteWhenNotLoggedInAlerts" 
    type="alert.type"
    close="closeCantVoteWhenNotLoggedInAlert($index)">{{ alert.msg }
</alert>

JavaScript:

//add
$scope.cantVoteWhenNotLoggedInAlerts.push({
  type: 'warning',
  msg: 'Must be logged in'
});                                

$scope.closeCantVoteWhenNotLoggedInAlert = function (index) {
  $scope.cantVoteWhenNotLoggedInAlerts.splice(index, 1);
};
+4
source share
1 answer

Try this method, it works

<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);
        };
0
source

Source: https://habr.com/ru/post/1530528/


All Articles