0

I want to call a particular value in my app through AngularJS

here is my controller(js file)

//infocomnamebyid
            $http.get('/csuv5.asmx/infocomname', {
                params: {
                    id: $scope.additionalinfoparam.Id
                }
            })
            .then(function (response) {
                {
                    $scope.comnamebyinfo = response.data.info;
                    console.log(response.data.info);
                }
            });
        }

the value is printing in console like this

    [Object]
0
:
Object
comname
:
"QED Productions Pvt Ltd"
__proto__
:
Object
length
:
1
__proto__
:
Array[0]

but now I want to print the same on my label

<label></label>
br.julien
  • 3,420
  • 2
  • 23
  • 44

3 Answers3

0

Give your label a model:

<label ng-model='aName'></label>

Then you can assign a value to it in your controller:

$scope.aName = response.data.info;
Phil Brockwell
  • 456
  • 5
  • 22
0

Try JSON.parse()

 $scope.comnamebyinfo = JSON.parse(response.data.info);

and in HTML,

 <label ng-model="comnamebyinfo"></label>
sisyphus
  • 452
  • 5
  • 13
0

There would be no reason to use two-way binding for a label. This means, instead of using the ng-model, you could:

1) String interpolation:

<label> {{ comnamebyinfo }}</label> 

or 2) The ng-bind directive:

<label ng-bind="comnamebyinfo"></label>

More information about the differences between those options can be found here.

Community
  • 1
  • 1
Eirini Graonidou
  • 1,506
  • 16
  • 24