gpt4 book ai didi

javascript - Angular JS 意外标记

转载 作者:行者123 更新时间:2023-12-03 11:10:40 29 4
gpt4 key购买 nike

团队,

当我尝试添加员工时,出现以下错误。我希望能够灵活地动态添加员工并填充列表屏幕。

另外,请告诉我,如何从不同的 JS 文件访问员工?

memory-services.js:8 Uncaught SyntaxError: Unexpected token var 2014-12-22 14:33:02.365angular.js:6 Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/undefined/$injector/modulerr?p0=myApp&p1=Error%…%20(http%3A%2F%2Flocalhost%3A8080%2Fdirectory%2Flib%2Fangular.js%3A28%3A48)

(function () {



var employees = [],

var addEmployeeDetail = {club_id:"27060",member_id:10118,member_name:"Rtn. Kuriachan K. A.",clasification:"Furniture Manufacturing",mobile_no:"9843677777",email_id:"kingskuri@hotmail.com",img_url:""};
addEmployee(addEmployeeDetail);
addEmployee = function(emp) {
employees.push(emp);
},

findById = function (id) {
var employee = null,
l = employees.length,
i;
for (i = 0; i < l; i = i + 1) {
if (employees[i].member_id === id) {
employee = employees[i];
break;
}
}
return employee;
},

findByManager = function (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));
}
}

}]);

}());

最佳答案

这是您的变量定义:

var employees = [],

var addEmployeeDetail = {
club_id: "27060",
member_id: 10118
/* ... */
};

请注意如何将 var 放在 , 运算符后面。这会导致语法错误。

您可以删除 var 或使用 ; 代替逗号,这样就可以解决问题。

关于javascript - Angular JS 意外标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27610085/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com