AngularJS: code not working when iterating through object [duplicate]
This question already has an answer here: 'this' vs $scope in AngularJS controllers 7 answers I am trying to populate a list of employee objects from my controller empctrl in a template. Here's the controller: app.controller('employeeController', function ($scope, employeeService) { this.employees = {}; this.populateTable = function (data) { this.employees = data; }; var error = function (err) { console.log("Error: " + err); }; // Call Service to List all Employees console.log("Service called to populate table."); employeeService.output().then(this.populateTable, error); this.populateTable();