Skip to main content
added 48 characters in body
Source Link
Mike
  • 811
  • 3
  • 22
  • 52

I have a dropdown in angularJS defined as:

$scope.Ids = [ {
                id : 'ID-100',
                name : 'ID-100'
            }, {
                id : 'ID-200',
                name : 'ID-200'
            }, {
                id : 'ID-300',
                name : 'ID-300'
            } ];
$scope.Id = $scope.Ids[0];

<select class="custom-select" ng-model="Id" ng-options="choice.name for choice in Ids"></select>

My requirement is to dynamically populate these Ids from DB.

I have a spring controller that makes a call to DB and yields a list. (i.e) it gives ID-100,ID-200 and ID-300:

$http({
                        'url' : '/getIds',
                        'method' : 'POST',
                        'headers' : {
                            'Content-Type' : 'application/json'
                        },
                        'params' : data
                    }).then(function(response) {
                        $scope.Ids = response.data.Ids;
                    });

and yields a list:

["ID-100", "ID-200", "ID-300"]
0: "ID-100"
1: "ID-200"
2: "ID-300"

My $scope.Ids will now be having the new list. I need to map this list to my $scope.Ids in dropdown format and make my dropdown display the first record.

Can someone give an idea on how to achieve this?

I have a dropdown in angularJS defined as:

$scope.Ids = [ {
                id : 'ID-100',
                name : 'ID-100'
            }, {
                id : 'ID-200',
                name : 'ID-200'
            }, {
                id : 'ID-300',
                name : 'ID-300'
            } ];
$scope.Id = $scope.Ids[0];

<select class="custom-select" ng-model="Id" ng-options="choice.name for choice in Ids"></select>

My requirement is to dynamically populate these Ids from DB.

I have a spring controller that makes a call to DB and yields a list. (i.e) it gives ID-100,ID-200 and ID-300

$http({
                        'url' : '/getIds',
                        'method' : 'POST',
                        'headers' : {
                            'Content-Type' : 'application/json'
                        },
                        'params' : data
                    }).then(function(response) {
                        $scope.Ids = response.data.Ids;
                    });

My $scope.Ids will now be having the new list. I need to map this list to my $scope.Ids in dropdown format and make my dropdown display the first record.

Can someone give an idea on how to achieve this?

I have a dropdown in angularJS defined as:

$scope.Ids = [ {
                id : 'ID-100',
                name : 'ID-100'
            }, {
                id : 'ID-200',
                name : 'ID-200'
            }, {
                id : 'ID-300',
                name : 'ID-300'
            } ];
$scope.Id = $scope.Ids[0];

<select class="custom-select" ng-model="Id" ng-options="choice.name for choice in Ids"></select>

My requirement is to dynamically populate these Ids from DB.

I have a spring controller that makes a call to DB:

$http({
                        'url' : '/getIds',
                        'method' : 'POST',
                        'headers' : {
                            'Content-Type' : 'application/json'
                        },
                        'params' : data
                    }).then(function(response) {
                        $scope.Ids = response.data.Ids;
                    });

and yields a list:

["ID-100", "ID-200", "ID-300"]
0: "ID-100"
1: "ID-200"
2: "ID-300"

My $scope.Ids will now be having the new list. I need to map this list to my $scope.Ids in dropdown format and make my dropdown display the first record.

Can someone give an idea on how to achieve this?

added 351 characters in body
Source Link
Mike
  • 811
  • 3
  • 22
  • 52

I have a dropdown in angularJS defined as:

$scope.Ids = [ {
                id : 'ID-100',
                name : 'ID-100'
            }, {
                id : 'ID-200',
                name : 'ID-200'
            }, {
                id : 'ID-300',
                name : 'ID-300'
            } ];
$scope.Id = $scope.Ids[0];

<select class="custom-select" ng-model="Id" ng-options="choice.name for choice in Ids"></select>

My requirement is to dynamically populate these Ids from DB.

I have a spring controller that makes a call to DB and yields a list. (i.e) it gives ID-100,ID-200 and ID-300

$http({
                        'url' : '/getIds',
                        'method' : 'POST',
                        'headers' : {
                            'Content-Type' : 'application/json'
                        },
                        'params' : data
                    }).then(function(response) {
                        $scope.Ids = response.data.Ids;
                    });

My $scope.Ids will now be having the new list. I need to map this list to my $scope.Ids in dropdown format and make my dropdown display the first record.

Can someone give an idea on how to achieve this?

I have a dropdown in angularJS defined as:

$scope.Ids = [ {
                id : 'ID-100',
                name : 'ID-100'
            }, {
                id : 'ID-200',
                name : 'ID-200'
            }, {
                id : 'ID-300',
                name : 'ID-300'
            } ];
$scope.Id = $scope.Ids[0];

<select class="custom-select" ng-model="Id" ng-options="choice.name for choice in Ids"></select>

My requirement is to dynamically populate these Ids from DB.

I have a spring controller that makes a call to DB and yields a list. (i.e) it gives ID-100,ID-200 and ID-300

I need to map this list to my $scope.Ids and make my dropdown display the first record.

Can someone give an idea on how to achieve this?

I have a dropdown in angularJS defined as:

$scope.Ids = [ {
                id : 'ID-100',
                name : 'ID-100'
            }, {
                id : 'ID-200',
                name : 'ID-200'
            }, {
                id : 'ID-300',
                name : 'ID-300'
            } ];
$scope.Id = $scope.Ids[0];

<select class="custom-select" ng-model="Id" ng-options="choice.name for choice in Ids"></select>

My requirement is to dynamically populate these Ids from DB.

I have a spring controller that makes a call to DB and yields a list. (i.e) it gives ID-100,ID-200 and ID-300

$http({
                        'url' : '/getIds',
                        'method' : 'POST',
                        'headers' : {
                            'Content-Type' : 'application/json'
                        },
                        'params' : data
                    }).then(function(response) {
                        $scope.Ids = response.data.Ids;
                    });

My $scope.Ids will now be having the new list. I need to map this list to my $scope.Ids in dropdown format and make my dropdown display the first record.

Can someone give an idea on how to achieve this?

Source Link
Mike
  • 811
  • 3
  • 22
  • 52

Dynamically populate dropdown - AngularJS

I have a dropdown in angularJS defined as:

$scope.Ids = [ {
                id : 'ID-100',
                name : 'ID-100'
            }, {
                id : 'ID-200',
                name : 'ID-200'
            }, {
                id : 'ID-300',
                name : 'ID-300'
            } ];
$scope.Id = $scope.Ids[0];

<select class="custom-select" ng-model="Id" ng-options="choice.name for choice in Ids"></select>

My requirement is to dynamically populate these Ids from DB.

I have a spring controller that makes a call to DB and yields a list. (i.e) it gives ID-100,ID-200 and ID-300

I need to map this list to my $scope.Ids and make my dropdown display the first record.

Can someone give an idea on how to achieve this?