Code Snippet:
Blinker.html
<html>
<head>
<title>Angular.js Example</title>
<script src="Scripts/angular.js"></script>
<script>
var nameApp = angular.module('NameApp', []);
nameApp.controller('NameCtrl', function ($scope) {
// I initialized only till alphabet 'H'.. Add more if you are topper in LKG.
$scope.letters = ['A-Apple', 'B-Ball', 'C-Cat', 'D-Dog', 'E-Elephant', 'F-Frog', 'G-Girafee', 'H-Horse'];
var time = 0;
$scope.testname = function (letter) {
setTimeout(function () {
$scope.test = letter;
$scope.$apply();
}, time);
time = time + 2000;
return letter;
}
});
</script>
</head>
<body ng-app="NameApp" ng-controller="NameCtrl">
<center>
<h1>Kids Alphabet Tutor</h1><br />
<div ng-hide="letter" ng-repeat="letter in letters">
<div ng-bind="testname(letter)"> </div>
</div>
<h1>
{{test}}
<img src="Images/{{test}}.PNG" width="75px" height="75px" />
</h1>
</center>
</body>
</html>
Points to Note:
- Image file Name should be the array element names initialized in the $scope.letters.
- Below is the folder structure:
After you make sure everything is ready run the Blinker.html and you see the below output.
This is how it looks:
