title: Angularjs service
body: <p>can anyone explain how to create a service in angular by factory method using simple example.I found some some example in some sites but i couldn't understand why there are 2 return statements and where there are returning the value and also in some examples there is only one return statement.please explain in step by step.</p>
  
  <pre><code>app.factory("squareService",function(){
          return{
                  square:function(n){
                      var a=n*n;
                      return a;
                  }
          };          
  
  });
  </code></pre>