Click here to Skip to main content
15,662,405 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a url from which I am retrieving state related data but I want to do it for all states. I am passing state as an argument from my html but unable to do so.
Please suggest how to do it. It is working for only one states.

What I have tried:

I have tried following
var myapp = angular.module('myApp', []);

myapp.controller("HttpPostController", function ($scope, $http) {

    $scope.SendHttpPostData = function () {

        var data = $.param({
            stnm: $scope.stateName,
        var statename = document.getElementById("stnm").value;
        var config = {
            headers : {
                'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
        if(statename==='AP') //here I want to handle for all states using else if condition.
        $http.get('https://myurl', data, config)

        .success(function (data, status, headers, config) {
            $scope.ServerResponse = data.records;

       .error(function (data, status, header, config) {


I want to handle based on my input it should handle for all states.
Updated 27-May-16 9:15am
Karthik_Mahalingam 27-May-16 5:09am    
instead of writing the $http.get in 'if else' you shall create a variable and assign to it in multiple 'if else' condition and at at last, call the $http.get
identity the common variable and modify it accordingly.
SNI 27-May-16 5:16am    
Thanks for your reply but for every state it has different resource_id and also fields names are also differ.
Karthik_Mahalingam 27-May-16 5:20am    
your code is confusing.
in data you have stateName
from stnm also you are getting the statename
what does that mean ?

there is no resource_id in the code..
post the relevant code..

SNI 27-May-16 5:25am    
you can see the resource_id in url that I have shared.
Karthik_Mahalingam 27-May-16 5:39am    
ok fine..
so what is the exact requirement
can you post the ng-controller code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900