title: $http.post not working inside ng-click function in Angular Js
body: <p>I'm developing a project with Anjular js and Codeigniter 3. I have faced some issues with routing in angular js. I have a view page with a  list of details of users and inside that list there is a tag with ng-click="myName()". I have declared this function inside my js file and this function works fine.</p>
  
  <pre><code>&lt;div class="container" ng-controller="ListController"&gt;
  
      &lt;div class="row"&gt;
          &lt;div class="col-lg-12 text-center"&gt;
              &lt;h1&gt;Starter Template&lt;/h1&gt;
              &lt;p class="lead"&gt;Complete with pre-defined file paths that you won't have to change&lt;/p&gt;
  
              &lt;div class="row"&gt;
                  &lt;div class="col-sm-6 col-md-4 wow zoomIn" data-wow-delay="0.5s" ng-repeat="items in artists"&gt;
                      &lt;div class="thumbnail"&gt;
                          &lt;img ng-src="{{settings.base_url}}/application/assets/images/profile/{{items.shortname}}.jpg" alt="..."&gt;
  
                          &lt;div class="caption"&gt;
                              &lt;h3&gt;{{items.name}}&lt;/h3&gt;
                              &lt;p&gt;{{items.bio}}&lt;/p&gt;
                              &lt;p&gt;&lt;a href="{{settings.base_url_controller}}auth/functionOne" class="btn btn-primary" ng-click="myName()" role="button"&gt;Button&lt;/a&gt; &lt;a href="#" class="btn btn-default" role="button"&gt;Button&lt;/a&gt;&lt;/p&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
  
  
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>Inside this function "myName()" I have written $http.post for getting a function inside the controller(Codeiginter controller). I'm using auth.php as controller and functionOne() is the function to retrive.</p>
  
  <pre><code>var base_url_abs = window.location.origin;
  var base_url = base_url_abs+'/AngularExPack/Angular_Bootstrap_CI_1/';
  var base_url_controller = base_url_abs+'/AngularExPack/Angular_Bootstrap_CI_1/index.php/';
  
      myApp.controller('ListController', ['$scope', '$http', 'settings', function($scope, $http) {
  
  $http.get('application/datas/data.json').success(function (data){
      $scope.artists =  data;
    });
  $scope.myName = function() {
           alert("hai1");
  /*
           $http.post(base_url_controller+'auth/functionOne/').success(function (response){
            $scope.data = response
            console.log(response);
            //alert($scope.data);
          });*/
  
  
      /**/ $http({
            method  : 'POST',
            url     : base_url_controller+'auth/functionOne/',
            headers : {'Content-Type': 'application/x-www-form-urlencoded'} 
           })
           .success(function(data) {
              $scope.data = response
            console.log($scope.data);
            alert($scope.data);
            });
  
      }
  
  }]);
  </code></pre>
  
  <p>When i run this, an error is occured and showing like this inside the console</p>
  
  <p><a href="https://i.stack.imgur.com/oet7R.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oet7R.png" alt="enter image description here"></a></p>
  
  <p>But i'm getting the correct result when i click on this link and also if i give base_url path inside the href inside a tag.</p>
  
  <pre><code>&lt;a href="{{settings.base_url_controller}}auth/functionOne" class="btn btn-primary" ng-click="myName()" role="button"&gt;Button&lt;/a&gt; &lt;a href="#" class="btn btn-default" role="button"&gt;Button&lt;/a&gt;
  </code></pre>
  
  <p>But what i need is inside this myName function i have to access the controller function functionOne() using $http using angular js. Is that possible.?</p>
  
  <p><strong>If anyone knows please help me to find out the solution in ng-click. Correct me if i written wrong code.</strong></p>
  
  <p>Thank you.</p>