Ng-Repeat-6

 

In this example we have an array named thumbnails with the id and name. With the help of ng-repeat directive we print the id and name of the thumbnail. We can also display the pictures instead of name of the thumbnail.

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Welcome to LearnKode - A code learning platform</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> </head> <body ng-app="app"> <div ng-controller="controllerName"> <div ng-repeat="thumbnail in thumbnails" style="height:200px;width:200px;border:2px solid black;float:left;margin-right:20px"> {{thumbnail.id}} <h3 style="text-align:center;vertical-align:central">{{thumbnail.name}}</h3> </div> </div> <script> var app = angular.module("app", []); app.controller('controllerName', ['$scope', function ($scope) { $scope.thumbnails = [{ id: '1', name: 'Div1' }, { id: '2', name: 'Div2' }, { id: '3', name: 'Div3' }, { id: '4', name: 'Div4' }]; }]); </script> </body> </html>
Output