title: Angularjs how to preserve url in function?
body: <p>Hi I am developing one Angularjs application. I have three cascading drop downs. Based on the selected values in drop down i am binding div with data received from api(div with ng-repeat). I have implemented paging. </p>
  
  <p>On page load i am binding first dropdown.</p>
  
  <pre><code>var arrMakes = new Array();
          $http.get(url + 'api' + '/Vehicle/' + 'GetVehicleMake').success(function (data) {
              $.map(data.data, function (item) {
                  arrMakes.push(item);
              });
              $scope.list = arrMakes;
              var dynamicUrl = url + 'api' + '/Vehicle/' + 'Getcars/';
              //bind data to Div randomly.
              getcadetails(dynamicUrl);
          }).error(function (status) {
          });
   function getcadetails(baseurl)
         {
             var arrallcarDetails = new Array();
             $http.get(baseurl,{ params: $scope.pagingInfo }).success(function (data) {
                      $.map(data.data, function (item) {
                       arrallcarDetails.push(item);
                       });
                      $scope.carDetails = arrallcarDetails;
                      $scope.pagingInfo.totalItems = data.totalcount;
               }).error(function (status) {
               });
          }
  </code></pre>
  
  <p>getcadetails is a function i am calling from different scenarios. For example, 
  ng-change event of first dropdown</p>
  
  <pre><code>  $scope.getModel = function (selectedMake) {
   var selectedMakeData = selectedMake.ID;
               var arrModel = new Array();
              $http.get(url + 'api' + '/Vehicle/' + selectedMakeData + '/GetVehicleModel').success(function (data) {
                  $.map(data.data, function (item) {
                      arrModel.push(item);
                  });
                  $scope.Modellist = arrModel;
                  var dynamicUrl = url + 'api' + '/Vehicle/' + 'Getcars/' + '?MakeID=' + selectedMakeData;
                  //bind data to Div randomly.
                  getcadetails(dynamicUrl);
              }).error(function (status) {
              });
  }
  </code></pre>
  
  <p>In paging i have below function. This is executed when i click on page numbers for example 1,2, etc</p>
  
  <pre><code>$scope.pageChanged = function (currentPage) {
                  $scope.pagingInfo.pageNumber = currentPage;
                  getcardetails();
              };
  </code></pre>
  
  <p>Here my problem starts. If i click on any page number $scope.pageChanged function executes. I will get page number to send it to server. after that i will call getcadetails(?). Now how can i get baseurl for getcadetails? Is there any way i can implement this in better way? Any help would be appreciated. Thank you.</p>