1

i am trying to display data in a table using angularJS ng-repeat. Data is not displayed. Here is my code : https://jsfiddle.net/807mxydL/. Thanks for your help

var custApp = angular.module('custApp', []);

var custApp = angular.module('custApp', []);

custApp.controller('CustomerController',function($http){

   this.nm = 1;

this.custs =

[{"custid":"1","custLnm":"Joshi","custFnm":"Amod","custCellno":"9970983214","custImgPath":"1.jpg"},{"custid":"2","custLnm":"Khare","custFnm":"Aditya","custCellno":"9860178001","custImgPath":"2.jpg"},{"custid":"3","custLnm":"Bhosale","custFnm":"Ketan","custCellno":"9890567713","custImgPath":"3.jpg"},{"custid":"4","custLnm":"Joshi","custFnm":"Rohit","custCellno":"9850703451","custImgPath":"4.jpg"},{"custid":"5","custLnm":"Bhat","custFnm":"Vidyut","custCellno":"9767211811","custImgPath":"5.jpg"},{"custid":"6","custLnm":"Chhadwa","custFnm":"Viraj","custCellno":"9767676767","custImgPath":"6.jpg"}
];

};

};

HTML code:

<div ng-app="custApp">
  <div ng-controller="CustomerControlleras customer">
        {{customer.nm}}
        <table>
             <tr>
               <td> id </td>
               <td> lnm </td>
               <td> fnm </td>
               <td> cell </td>
               <td> img </td>
             </tr>
             <tr ng-repeat="c in customer.custs">
               <td>{{c.custid}}</td>
               <td>{{c.custLnm}}</td>
               <td>{{c.custFnm}}</td>
               <td>{{c.custCellno}}</td>
               <td>{{c.custImgPath}}</td>
             </tr>
        </table>
  </div>
</div>
1
  • change to <div ng-controller="CustomerController as customer"> Commented Apr 11, 2017 at 21:31

1 Answer 1

1

Try like this

you have some mistakes.

1: <div ng-controller="CustomerController as customer">

2:forgot put ) in end of controller

var custApp = angular.module('custApp', []);
custApp.controller('CustomerController',function($http){
   this.nm = 1;
   this.custs = [{"custid":"1","custLnm":"Joshi","custFnm":"Amod","custCellno":"9970983214","custImgPath":"1.jpg"},{"custid":"2","custLnm":"Khare","custFnm":"Aditya","custCellno":"9860178001","custImgPath":"2.jpg"},{"custid":"3","custLnm":"Bhosale","custFnm":"Ketan","custCellno":"9890567713","custImgPath":"3.jpg"},{"custid":"4","custLnm":"Joshi","custFnm":"Rohit","custCellno":"9850703451","custImgPath":"4.jpg"},{"custid":"5","custLnm":"Bhat","custFnm":"Vidyut","custCellno":"9767211811","custImgPath":"5.jpg"},{"custid":"6","custLnm":"Chhadwa","custFnm":"Viraj","custCellno":"9767676767","custImgPath":"6.jpg"}
];

});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="custApp">
  <div ng-controller="CustomerController as customer">
        {{customer.nm}}
        <table>
             <tr>
               <td> id </td>
               <td> lnm </td>
               <td> fnm </td>
               <td> cell </td>
               <td> img </td>
             </tr>
             <tr ng-repeat="c in customer.custs">
               <td>{{c.custid}}</td>
               <td>{{c.custLnm}}</td>
               <td>{{c.custFnm}}</td>
               <td>{{c.custCellno}}</td>
               <td>{{c.custImgPath}}</td>
             </tr>
        </table>
  </div>
</div>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.