Hey Team,
I encountered an error while trying to add an employee. I'm looking for a way to dynamically add employees and display them on the list screen.
Additionally, how can I access the employees from a different JS file?
A SyntaxError occurred at memory-services.js:8 - Unexpected token var. Also, there's an AngularJS error at angular.js:6. Click here for more details.
(function () {
var employees = [],
addEmployeeDetail = {club_id:"27060",member_id:10118,member_name:"Rtn. Kuriachan K. A.",clasification:"Furniture Manufacturing",mobile_no:"9843677777",email_id:"[email protected]",img_url:""};
addEmployee(addEmployeeDetail);
function addEmployee(emp) {
employees.push(emp);
}
function findById(id) {
var employee = null,
l = employees.length,
i;
for (i = 0; i < l; i++) {
if (employees[i].member_id === id) {
employee = employees[i];
break;
}
}
return employee;
}
function findByManager(managerId) {
var results = employees.filter(function(element) {
return managerId === element.managerId;
});
return results;
}
angular.module('myApp.memoryServices', [])
.factory('Employee', [
function() {
return {
query: function() {
return employees;
},
get: function(employee) {
return findById(parseInt(employee.employeeId));
}
}
]);
}());