The demo below is created using a Calculator service with an API, calculate. The service is injected into a Controller and then the API, calculate is invoked on that service.

{{result}}

Calculator Service with calculate API
			
function Calculator() {
      
      this.calculate = function( no1, no2, optype ) {
          var result = 0;
          switch( optype ) {
            case '+':
              result = add( no1, no2);
              break;
            case '-':
              result = subtract( no1, no2);
              break;
            case '*':
              result = multiply(  no1, no2);
              break;
            case '/':
              result = divide(  no1, no2);
              break;
            default:
          }
          return result;
      }
      var add = function( no1, no2 ) {
          return no1 + no2;
      }
      var subtract = function( no1, no2 ) {
          return no1 - no2;
      }
      var multiply = function( no1, no2 ) {
          return no1 * no2;
      }
      var divide = function( no1, no2 ) {
          return no1 / no2;
      }
      
    }