title: Even or Odd program in AngularJS
body: <p>I am trying to write an even or odd program in angularJs.
  In the below code I have defined my own user-defined service to identify whether a number is even or odd it will work fine when the value is hardcoded. But when I try to give realtime value using the input method I am unable to get the desired answer. Please help me with this.</p>
  
  <p>Code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"&gt;&lt;/script&gt;
  &lt;body&gt;
  &lt;div ng-app='myApp' ng-controller='myCtrl'&gt;
      &lt;input type='number' name='num' ng-model='num'&gt;&lt;br&gt;
      &lt;b&gt;The number Entered is {{num}} which is {{myUserService}} &lt;/b&gt;
  &lt;/div&gt;
  &lt;script&gt;
  angular.module('myApp',[]).service('myService',function(){
              this.myFunc=function(x){
                  if(x%2==0)
                      return 'EVEN';
                  else
                      return 'ODD';
                  };
              }).controller('myCtrl',function($scope,myService){
                  $scope.myUserService= myService.myFunc($scope.num);
            });
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <ul>
  <li>List item</li>
  </ul>