为什么我们不能使用与ng-model相同的JsonKeyName?

时间:2014-07-14 07:03:28

标签: javascript angularjs

我有一个JSON对象PayheadsEmpMap数组,在这里我有empData,并且我有一些员工数据。每位员工都附上一份PayRoll信息。这包含OnetimeData。这整个结构重演。我使用了PayHeadData.payHeadValue作为ng-model(同样的结构重复了很多次)。

现在的问题是,当我在PayHeadEmpMap中重复多个元素时,ng-model的值对一个员工填充,在下一个相同的索引上填充,所以ng-repeat。

我希望ng-model具有独特的价值。

<div ng-repeat="payheademp in PayheadsEmpMap"  my-users-post-menu-creation-directive>
        <div class="toHideAll"  id="idOfDataDiv_{{payheademp.ph_id}}"  ><!-- ng-show="showDiv($index,payheademp.ph_id)" -->
            <table style="width:100%">
                        <tbody >
                            <tr ng-repeat='employee in payheademp.empData'>
                                <td class="row-label"  style="width:60%;text-align:left">
                                    <span ><span class="BodyTxt3Bold">{{employee.fname + " " }}{{employee.mname + " "}}{{employee.lname}} </span>({{employee.gen_id}}){{", "+employee.employee_designation}}{{", "+employee.location_name}}</span>
                                </td>
                                <td  ng-repeat="OneTimeData in employee.PayHeadData" class="row-label" style="width:40%;text-align:left;vertical-align:top">
                                    <input  ng-model="OneTimeData.payHeadaValue" style="float:left" id=idOfInp_{{OneTimeData.payheadId}}_{{employee.employee_id}} type="text" onkeyup="checkForInput(this);" class="W4_Normal V3 two-decimals">
                                </td>
                             </tr>
                        </tbody>
            </table>
        </div>
    </div>

数据:

  {
        "phr_id": 0,
        "ph_cust_id": 0,
        "phr_cust_id": 0,
        "ph_id": 1,
        "phr_sys_sal_flag": 0,
        "phr_att_unit": 0,
        "phr_rule_flag": 0,
        "phr_formula_flag": 0,
        "ph_pslip_app": 0,
        "employee_id": 0,
        "ph_nature": 0,
        "phr_prd_flag": 0,
        "comp": 0,
        "ph_rnd_type": 0,
        "ph_rnd_to": 0,
        "phr_att": 0,
        "phr_rule": 0,
        "ph_type": 0,
        "phr_att_unit_flag": 0,
        "ph_category": 0,
        "ph_active": 0,
        "ph_ctc_app": 0,
        "phr_att_type_flag": 0,
        "phr_att_flag": 0,
        "phr_created_offset": 0,
        "ph_created_offset": 0,
        "phr_rule_offset": 0,
        "phr_basis_flag": 0,
        "ph_name": "PayHead Menu First",
        "ph_subtype": 0,
        "phr_basis": "P",
        "ph_add_all": 1,
        "phr_ph_id": 0,
        "empData": [{
            "function_id": 3,
            "grade_id": 3,
            "role_id": 22,
            "location_id": 2,
            "employee_designation": "Finance manager",
            "bu_id": 172,
            "gen_id": "23",
            "employee_id": 824,
            "emp_type": 6,
            "fname": "parmr",
            "location_name": "corporate",
            "level_id": 69,
            "lname": "rathour",
            "mname": "r",
            "$$hashKey": "02E",
            "PayHeadData": [{
                "payheadId": 14,
                "payHeadaValue": "",
                "empId": 824,
                "$$hashKey": "059"
            }]
        }, {
            "function_id": 444,
            "grade_id": 3,
            "role_id": 3,
            "location_id": 2,
            "employee_designation": "df",
            "bu_id": 169,
            "gen_id": "27",
            "employee_id": 825,
            "emp_type": 9,
            "fname": "Jeet",
            "location_name": "corporate",
            "level_id": 3,
            "lname": "Yadav",
            "$$hashKey": "02F",
            "PayHeadData": [{
                "payheadId": 14,
                "payHeadaValue": "",
                "empId": 825,
                "$$hashKey": "05B"
            }]
        }, {
            "function_id": 3,
            "grade_id": 3,
            "role_id": 3,
            "location_id": 2,
            "employee_designation": "sdf",
            "bu_id": 169,
            "gen_id": "234324390",
            "employee_id": 831,
            "emp_type": 9,
            "fname": "Ganga",
            "location_name": "corporate",
            "level_id": 3,
            "lname": "Ram",
            "$$hashKey": "02G",
            "PayHeadData": [{
                "payheadId": 14,
                "payHeadaValue": "",
                "empId": 831,
                "$$hashKey": "05D"
            }]
        }, {
            "function_id": 3,
            "grade_id": 3,
            "role_id": 23,
            "location_id": 2,
            "employee_designation": "sfsfsf",
            "bu_id": 169,
            "gen_id": "234324391",
            "employee_id": 832,
            "emp_type": 9,
            "fname": "Ram",
            "location_name": "corporate",
            "level_id": 3,
            "lname": "Ram",
            "$$hashKey": "02H",
            "PayHeadData": [{
                "payheadId": 14,
                "payHeadaValue": "",
                "empId": 832,
                "$$hashKey": "05F"
            }]
        }, {
            "function_id": 444,
            "grade_id": 3,
            "role_id": 21,
            "location_id": 136,
            "employee_designation": "Customer S",
            "bu_id": 169,
            "gen_id": "234324392",
            "employee_id": 842,
            "emp_type": 9,
            "fname": "Veenu",
            "location_name": "new Delhi 11",
            "level_id": 72,
            "lname": "Vashishtha",
            "$$hashKey": "02I",
            "PayHeadData": [{
                "payheadId": 14,
                "payHeadaValue": "",
                "empId": 842,
                "$$hashKey": "05H"
            }]
        }, {
            "function_id": 444,
            "grade_id": 3,
            "role_id": 21,
            "location_id": 136,
            "employee_designation": "Customer S",
            "bu_id": 169,
            "gen_id": "234324393",
            "employee_id": 843,
            "emp_type": 9,
            "fname": "Veenu",
            "location_name": "new Delhi 11",
            "level_id": 72,
            "lname": "Vashishtha",
            "$$hashKey": "02J",
            "PayHeadData": [{
                "payheadId": 14,
                "payHeadaValue": "",
                "empId": 843,
                "$$hashKey": "05J"
            }]
        }],
        "$$hashKey": "03S"
    }

0 个答案:

没有答案