ng-repeat not working with table,in the output only header part displayed? As i think the binding i did is perfectly fine, but something is there which i am missing? When i try to run in Stackoverflow ide it is working fine.
I am using ADOBE Brackets.whether its the error in brackets?? Please suggest the best IDE for angularjs ? Can anyone help me out where i am doing wrong?
var myApp=angular.module("myApp",[]); var mycontroller=function($scope) { var employees=[ {Name:'Sahil',dateOfBirth:new Date(),gender:"Male",salary: 400000}, {Name:'Shaloni',dateOfBirth:new Date(),gender:"Female",salary: 100000}, {Name:'Nitish',dateOfBirth:new Date(),gender:"Male",salary: 300000}, {Name:'Diksha',dateOfBirth:new Date(),gender:"Female",salary: 600000}, {Name:'Tarun',dateOfBirth:new Date(),gender:"Male",salary: 900000} ] $scope.emp=employees; }; myApp.controller('myController',mycontroller);
<HTML ng-app="myApp"> <Head> <title></title> <script src="https://code.angularjs.org/1.5.0-rc.0/angular.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script> <script src="day4.js"></script> <link href="Style.css" rel="stylesheet"/> </Head> <body> <div ng-controller="myController"> <table> <thead> <th>Name</th> <th>Date Of Birth</th> <th>Gender</th> <th>Salary</th> <th>Salary in Dollors</th> </thead> <tbody> <tr ng-repeat="employee in emp"> <td>{{employee.Name}}</td> <td>{{employee.dateOfBirth}}</td> <td>{{employee.gender}}</td> <td>{{employee.salary}}</td> <td></td> </tr> </tbody> </table> </div> </body> </HTML>
Please find your solution , https://plnkr.co/edit/hFIfPlTcP8VLVE72coth
And problem in your code is here : var mycontroller=function($scope) and myApp.controller('myController',mycontroller);
mycontroller variable is not getting called. put Alert(); in that block and see.
And for editor you can use SUBLIME editor , Visual studio code, : Intellisense for angular2
var myApp=angular.module("myApp",[]); var mycontroller=function($scope) { var employees=[ {Name:'Sahil',dateOfBirth:new Date(),gender:"Male",salary: 400000}, {Name:'Shaloni',dateOfBirth:new Date(),gender:"Female",salary: 100000}, {Name:'Nitish',dateOfBirth:new Date(),gender:"Male",salary: 300000}, {Name:'Diksha',dateOfBirth:new Date(),gender:"Female",salary: 600000}, {Name:'Tarun',dateOfBirth:new Date(),gender:"Male",salary: 900000} ] $scope.emp=employees; }; myApp.controller('myController',mycontroller);
<HTML ng-app="myApp"> <Head> <title></title> <script src="https://code.angularjs.org/1.5.0-rc.0/angular.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script> <script src="day4.js"></script> <link href="Style.css" rel="stylesheet"/> </Head> <body> <div ng-controller="myController"> <table> <thead> <th>Name</th> <th>Date Of Birth</th> <th>Gender</th> <th>Salary</th> <th>Salary in Dollors</th> </thead> <tbody> <tr ng-repeat="employee in emp"> <td>{{employee.Name}}</td> <td>{{employee.dateOfBirth}}</td> <td>{{employee.gender}}</td> <td>{{employee.salary}}</td> <td></td> </tr> </tbody> </table> </div> </body> </HTML>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.