title: Uncaught TypeError: app.all is not a function
body: <p>I have a very simple angular page here </p>
  
  <pre><code>&lt;script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.js"&gt;&lt;/script&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"&gt;&lt;/script&gt;
  
  &lt;div ng-app="myApp" ng-controller="myCtrl"&gt;
  
    &lt;p&gt;Today's welcome message is:&lt;/p&gt;
    &lt;h1&gt;{{myData}}&lt;/h1&gt;
  
  &lt;/div&gt;
  
  &lt;script&gt;
  
    var app = angular.module('corsApp', []);
  
    app.config(['$httpProvider', function($httpProvider) {
      $httpProvider.defaults.useXDomain = true;
      delete $httpProvider.defaults.headers.common['X-Requested-With'];
  
    }
  
    ]);
  
  
    // Added all header request and response.
    app.all('/*', function (request, response, next) {
      response.header("Access-Control-Allow-Origin", "*");
      response.header("Access-Control-Allow-Headers", "X-Requested-With");
      response.header("Access-Control-Allow-Methods", "GET, POST", "PUT", "DELETE");
      next();
    });
  
  
  
    app.controller('myCtrl', function($scope, $http) {
      $http.get("welcome.htm")
      .then(function(response) {
          $scope.myWelcome = response.data;
      });
  });
  
  
  &lt;/script&gt;
  </code></pre>
  
  <hr>
  
  <p>I kept getting this in my console.</p>
  
  <p><strong>Uncaught TypeError: app.all is not a function</strong></p>
  
  <p>How do I prevent that ? </p>
  
  <p>I'm following this : </p>
  
  <p><a href="https://stackoverflow.com/a/21455819/4480164">https://stackoverflow.com/a/21455819/4480164</a></p>