Thiyagarajan Thiyagarajan - 3 years ago 151
AngularJS Question

Ng-bind is not working

I have a issue in data binding using angularjs

I am trying to bind the data from the controller view.
data has been successfully received in the response. i have assigned it in the datalist. while trying to loop the datalist using ng-repeat and ng-bind i cannot able to view.
seems ng-repeat is working i can able to see the index looping successfully.
Kindly help on this issue.

Html

<tbody>
<tr ng-repeat="data in dataList">
<td>{{$index+1}}</td>
<td ng-bind="data.Name"></td>
<td ng-bind="data.Email"></td>
<td ng-bind="data.Phone"></td>
</tr>
</tbody>


Angular Js

var myApp = angular.module('myModule', []);
myApp.controller('myController', function ($scope, $http) {
$scope.dataList = [];
$http.get('/Home/JsonValue').then(function (response) {
if (response != null || response != "undefined") {
$scope.dataList = response;
}
})
});


Json Data

Data: Array(5)
0:{Name: "Pramod", Email: "Pramod@gmail.com", Phone: "987654321"}
1:{Name: "Prem", Email: "Prem@gmail.com", Phone: "123456789"}
2:{Name: "Ram", Email: "Ram@gmail.com", Phone: "9811234343"}
3:{Name: "Shyam", Email: "Shyam@gmail.com", Phone: "9889657454"}
4:{Name: "Jitesh", Email: "Jitesh@gmail.com", Phone: "9535468899"}

Answer Source

You should access the data property of response

 $http.get('/Home/JsonValue').then(function (response) {
      if (response != null || response != "undefined") {
        $scope.dataList = response.data;
 }
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download