jeudi 14 janvier 2016

show modal when checkbox is check or uncheck

Click here to view my code: http://ift.tt/1JNIU2h

HTML:

<ul>
<li ng-repeat="album in albums">
  <input type="checkbox" ng-model="album.selected" value={{album.name}} ng-click="save()"/> {{album.name}}
</li>

Script:

$scope.save = function(item){
 $scope.mods = item;
  $scope.albumNameArray = [];
  angular.forEach($scope.albums, function(album){
  if (album.selected) $scope.albumNameArray.push(album.name);
  return false;
  });
 };
 $scope.edit = function(){
            if ($scope.albumNameArray ) {
                            $('#showModal').modal('show');
                        } else {
                            $('#showModal2').modal('show');
                        }

          }

My project is working fine if I click the save button without checking the checkbox but If I check and then uncheck it, same modal was appearing. This works fine only in first reload. I want to make is, if I check the checkbox, ok modal will show else other one modal will show without reloading




Aucun commentaire:

Enregistrer un commentaire