AngularJS Tutorial - Click to load image








The following code shows how to Click to load image.

Example


<!DOCTYPE html>
<html  ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
<script type='text/javascript'>
function ShowHideController($scope) {<!--from  www. j av a  2 s.  c  o m-->
    $scope.showImage = function(){
        $scope.images = ['http://www.java2s.com/style/download.png'];
    }
}
</script>
</head>
<body>
  <div ng-app ng:controller="ShowHideController">
    <div ng-repeat='image in images'>
        <img ng-src="{{image}}"/>
    </div>
    <button ng-click='showImage()'> show image </button>
<div>
</body>
</html>

The code above is rendered as follows: