Thursday, June 25, 2015

Palindrome in AngularJS

Code Snippet:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Check whether the given word is palindrome or not</title>
    <script src="Scripts/angular.js"></script>
    <script type="text/javascript">
        var app = angular.module('palindromeApp', []);
        app.controller('palindromeController', ['$scope'function ($scope) {
            $scope.palicheck = function (word) {
                var revword = word.split('').reverse().join('');
                return revword == word;
            };
        }]);
    </script>
</head>
<body ng-app="palindromeApp" ng-controller="palindromeController">
    <h3>Check whether the given word is palindrome or not</h3>
    <div>
        Enter Word: <input type="text" ng-model="word" />
    </div>
    <div ng-if="palicheck(word)">The Given word <b>{{word}}</b> is palindrome</div>
    <div ng-if="!palicheck(word)">The Given word <b>{{word}}</b> is not palindrome</div>
</body>
</html>

How it Looks:

1 comment:

  1. Excellent information with unique content and it is very useful to know about the information based on blogs.
    Angularjs Training In Hyderabad

    ReplyDelete