Skip to content Skip to sidebar Skip to footer

How To View The Image In Fullscreen Using Ng-repeat?

I'm expecting something like this https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_modal_img but it seems to not work when using ng-repeat

Solution 1:

Please run below code. I hope it will solve your problem.

angular.module('selectExample', [])
  .controller('ExampleController', ['$scope', function($scope) {

    $scope.register = {
      regData: {
        branch: {},
      },
      names: [{
        name: "narquois",
        image: [{
          'image': "https://picsum.photos/200",
          'flag': false
        }, {
          'image': "https://picsum.photos/200/300/",
          'flag': false
        }]

      }],
    };
    $scope.getBig = function(key, value) {
      $scope.register.names[0].image[key].flag = true;
    }
    $scope.close = function(key, value) {
      $scope.register.names[0].image[key].flag = false;
    }
  }]);
.imgSmall {
  width: 70px;
}


/* The Modal (background) */.modal {
  /* Hidden by default */position: fixed;
  /* Stay in place */z-index: 1;
  /* Sit on top */padding-top: 100px;
  /* Location of the box */left: 0;
  top: 0;
  width: 100%;
  /* Full width */height: 100%;
  /* Full height */overflow: auto;
  /* Enable scroll if needed */background-color: rgb(0, 0, 0);
  /* Fallback color */background-color: lightblue;
}


/* Modal Content (image) */.modal-content {
  margin: auto;
  display: block;
  width: 80%;
  max-width: 700px;
}


/* Caption of Modal Image */#caption {
  margin: auto;
  display: block;
  width: 80%;
  max-width: 700px;
  text-align: center;
  color: #ccc;
  padding: 10px0;
  height: 150px;
}


/* Add Animation */.modal-content,
#caption {
  -webkit-animation-name: zoom;
  -webkit-animation-duration: 0.6s;
  animation-name: zoom;
  animation-duration: 0.6s;
}

@-webkit-keyframes zoom {
  from {
    -webkit-transform: scale(0)
  }
  to {
    -webkit-transform: scale(1)
  }
}

@keyframes zoom {
  from {
    transform: scale(0)
  }
  to {
    transform: scale(1)
  }
}


/* The Close Button */.close {
  position: absolute;
  top: 15px;
  right: 35px;
  color: #f1f1f1;
  font-size: 40px;
  font-weight: bold;
  transition: 0.3s;
  cursor: pointer;
}
<scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.5/angular.min.js"></script><divng-app="selectExample"ng-controller="ExampleController"><tableid="example"width="100%"><trng-repeat="person in register.names"><tdalign="center">{{ person.name }}</td><tdalign="center"ng-repeat="(key,image) in person.image"><imgclass="imgSmall"ng-src="{{image.image}}"ng-click="getBig(key,image)"><divng-show="image.flag"id="myModal"class="modal"><spanclass="close"ng-click="close(key,image)">&times;</span><imgclass="modal-content"ng-src="{{image.image}}"id="img01"><divid="caption"></div></div></td></tr></table></div>

Post a Comment for "How To View The Image In Fullscreen Using Ng-repeat?"