title: Service not defined in angular js
body: <p>I am getting error of service not defined in angular js but I cant figure out why as my controller and module is perfectly connected:</p>
  
  <p>application.js:</p>
  
  <pre><code>var myapp=angular.module('myApp', []);
  
  myapp.service('productService', function() {
    var productList = "";
  
    var addProduct = function(newObj) {
       productList=newObj;
    };
  
    var getProducts = function(){
        return productList;
    };
  
    return {
      addProduct: addProduct,
      getProducts: getProducts
    };
  
  });
  </code></pre>
  
  <p>controller1.js:</p>
  
  <pre><code>myapp.controller('contrl1', ['$scope','productService', function ($scope) {
      var st="datsat";
  
       productService.addProduct(st);
  </code></pre>
  
  <p>}]);</p>
  
  <p>Controller 2:</p>
  
  <pre><code>myapp.controller('contrl2', ['$scope','productService', function ($scope) {
  
   $scope.products = productService.getProducts();
  }]);
  </code></pre>
  
  <p>Also in the views I have given link to contoller.js file and application.js file</p>