title: Lodash in Angular JS - getting TypeError: Object function lodash(value)
body: <p>i've created an application in angular for performing a simple calculator.
  The application works fine (<a href="http://jsfiddle.net/pz5Jc/5/" rel="nofollow">demo</a>) but here in the controller within the calculate method i've wrote some arithmetic calculation in javascript. So to make my angular code clean i created another file named common.js where i placed that arithmetic calculations. I'm using lodash.js. but when i tried to call the method <code>_.calculateResult($scope.firstNumber, $scope.secondNumber, $scope.selectedOperator );</code> i'm getting the following exception.</p>
  
  <pre><code>TypeError: Object function lodash(value) {
        // don't wrap if already wrapped, even if wrapped by a different `lodash` constructor
        return (value &amp;&amp; typeof value == 'object' &amp;&amp; !isArray(value) &amp;&amp; hasOwnProperty.call(value, '__wrapped__'))
         ? ...&lt;omitted&gt;... } has no method 'calculateResult'
      at Object.$scope.calculate (http://localhost:8080/RestSample/app/scripts/controllers.js:18:19)
  </code></pre>
  
  <p>can anyone please tell me some solution for this.</p>
  
  <p><strong>common.js</strong>  </p>
  
  <pre><code>(function() {
  
  var calculateResult = function(no1, no2, opp) {
  var A = parseInt(no1);
  var B = parseInt(no2);
  var C = 0;
  
  switch (opp) {
        case '+':
        C = A + B;
        break;
        case '-':
        C = A - B;
        break;
        case '*':
        C = A * B;
        break;
        case '/':
        C = A / B;
        break;                
     }
  
     return C;
  }
  
  })();
  </code></pre>
  
  <p><strong>controllers.js</strong></p>
  
  <pre><code>    var app = angular.module('app', []);
  
      app.controller("appController", function($scope){
          $scope.operators = ['+', '-', '*', '/'];
          $scope.selectedOperator = $scope.operators[0];
  
          $scope.calculate = function() {
  $scope.result = _.calculateResult($scope.firstNumber, $scope.secondNumber, $scope.selectedOperator );
  
          };
      });
  </code></pre>
  
  <p><strong>index.html</strong></p>
  
  <pre><code>    &lt;div ng-app="app"&gt;
          &lt;div ng-controller="appController"&gt;
  
       &lt;div class="offset4 span6 well"&gt;
       &lt;label&gt;Enter a value :&lt;/label&gt;
       &lt;input ng-model="firstNumber" type="text"&gt; &lt;br/&gt;&lt;br&gt;
  
  
       &lt;label&gt;Another Value:&lt;/label&gt;
       &lt;input ng-model="secondNumber" type="text"&gt; &lt;br/&gt;&lt;br&gt;
  
       &lt;label&gt;Operator:&lt;/label&gt;
       &lt;select ng-model="selectedOperator" 
       ng-options="operator for operator in operators"&gt;&lt;/select&gt; 
       &lt;br&gt;&lt;br&gt;
  
       &lt;button ng-click="calculate()"&gt;Calculate&lt;/button&gt; &lt;br&gt;&lt;br&gt;
  
       Result: {{result}}
       &lt;/div&gt;
       &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>