title: How can we use service just like a factory?
body: <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html ng-app='myApp'&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"&gt;&lt;/script&gt;
  
  &lt;script&gt;
      var app = angular.module('myApp', []);
      app.controller('x', function (ser) {
          alert(ser.val);
      });
      app.service('ser', function () {
          var obj = {};
          obj.val = 'xyz';
          return obj;
      })
  &lt;/script&gt;
  
  &lt;body&gt;
  
      &lt;h1 ng-controller='x'&gt;My First JavaScript Animation&lt;/h1&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>We can create on object and give the object properties and return it in factories,but service is a constructor function,but here in the program i'm doing the same as i should do in factory by creating and returning an object.
  Isn't it should be done using this keyword...but it's working.how?</p>