JavaScript ngRepeat:dupes error, although there is no duplication ngrepeat dupes error,ng-repeat dupes error in angularjs,angular

I have a HTML code like below which I use AngularJS framework within it:

<select name="choose-staff" ng-model="admin_times[0].user"  ng-change="update(reserve.staff)" id="choose-staff">
     <option ng-repeat="value in staff | unique:'employee.user.username'" value="{[{ value.employee.user.username }]}">{[{ value.employee.user.first_name }]} {[{ value.employee.user.last_name }]}</option>
</select>

And I get an error like this:

Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys. Repeater: value in staff | unique:'employee.user.username', Duplicate key: string:ب, Duplicate value: ب

And if I use track by $index it destroys my desired structure and when I click one of options, the rest of them get vanished.

[
    {
        "employee": {
            "user": {
                "id": 3,
                "first_name": "اشکان",
                "last_name": "وکیلی",
                "user_profile": null,
                "username": "ashkan"
            },
            "business": {
                "id": "caf241cd-adb4-44ee-8c40-0f6cdb3bc5ac",
                "fa_name": "ساینا",
                "en_name": "Saina",
                "service": [],
                "persian_address": "",
                "location": "35.77885523664743,51.39051060551765",
                "avatar": null,
                "email": ""
            },
            "is_head": true
        },
        "service": {
            "en_title": "Haircut",
            "fa_title": "کوتاهی مو"
        },
        "allocated_time": 60,
        "booked_no": "XG4OCX81"
    },
    {
        "employee": {
            "user": {
                "id": 3,
                "first_name": "اشکان",
                "last_name": "وکیلی",
                "user_profile": null,
                "username": "ashkan"
            },
            "business": {
                "id": "caf241cd-adb4-44ee-8c40-0f6cdb3bc5ac",
                "fa_name": "ساینا",
                "en_name": "Saina",
                "service": [],
                "persian_address": "",
                "location": "35.77885523664743,51.39051060551765",
                "avatar": null,
                "email": ""
            },
            "is_head": true
        },
        "service": {
            "en_title": "Color",
            "fa_title": "رنگ مو"
        },
        "allocated_time": 25,
        "booked_no": "1AY3F24G"
    },
    {
        "employee": {
            "user": {
                "id": 2,
                "first_name": "رضا",
                "last_name": "ولیمرادی",
                "user_profile": {
                    "id": "9d9be03a-f840-46ea-a21e-76cd5775a886",
                    "avatar": null,
                    "city": "",
                    "gender": "F",
                    "birthday": null,
                    "country": "IR",
                    "about": "",
                    "timestamp": "2015-11-06T14:56:10.312340Z",
                    "location": "36.03133177633187,51.328125"
                },
                "username": "reza"
            },
            "business": {
                "id": "caf241cd-adb4-44ee-8c40-0f6cdb3bc5ac",
                "fa_name": "ساینا",
                "en_name": "Saina",
                "service": [],
                "persian_address": "",
                "location": "35.77885523664743,51.39051060551765",
                "avatar": null,
                "email": ""
            },
            "is_head": false
        },
        "service": {
            "en_title": "Yellow",
            "fa_title": "زرد"
        },
        "allocated_time": 15,
        "booked_no": "H989M93X"
    },
    {
        "employee": {
            "user": {
                "id": 1,
                "first_name": "علیرضا",
                "last_name": "غفاری",
                "user_profile": {
                    "id": "884b36e3-7bad-466f-afee-25801572b834",
                    "avatar": null,
                    "city": "",
                    "gender": "F",
                    "birthday": null,
                    "country": "IR",
                    "about": "",
                    "timestamp": "2015-11-06T14:56:39.522362Z",
                    "location": "32.24997445586331,53.26171875"
                },
                "username": "alireza"
            },
            "business": {
                "id": "caf241cd-adb4-44ee-8c40-0f6cdb3bc5ac",
                "fa_name": "ساینا",
                "en_name": "Saina",
                "service": [],
                "persian_address": "",
                "location": "35.77885523664743,51.39051060551765",
                "avatar": null,
                "email": ""
            },
            "is_head": true
        },
        "service": {
            "en_title": "Color",
            "fa_title": "رنگ مو"
        },
        "allocated_time": 20,
        "booked_no": "O5KLFPZB"
    }
]

I don't like the redundancy of employee.user.username

Answer:1

I tried to call .map on Uint8Array and got a surprise. const tt = new Uint8Array(1); tt[0] = 0xFF; const ttt = tt.map(x => x.toString(2)); console.log(ttt[0]); console.log(tt[0]....

I tried to call .map on Uint8Array and got a surprise. const tt = new Uint8Array(1); tt[0] = 0xFF; const ttt = tt.map(x => x.toString(2)); console.log(ttt[0]); console.log(tt[0]....

I have to populate a third select based on second. I'm trying like code below. As it is I'm feeding first select with all countries in DB. Second select is feeded based on first select. I need to ...

I have to populate a third select based on second. I'm trying like code below. As it is I'm feeding first select with all countries in DB. Second select is feeded based on first select. I need to ...

kindly assist me to know why when i call a function and pass a parameter using a string in its 'raw form' i get the right output but when i assign it to a variable first i get a different output. i ...

kindly assist me to know why when i call a function and pass a parameter using a string in its 'raw form' i get the right output but when i assign it to a variable first i get a different output. i ...

EDIT: I have to make this work on IE11 I have the following code: span.classList.add(span.textContent === '\ ' ? 'char' : 'spaceChar') It is working fine, but I would like to add 2 classes in case ...

EDIT: I have to make this work on IE11 I have the following code: span.classList.add(span.textContent === '\ ' ? 'char' : 'spaceChar') It is working fine, but I would like to add 2 classes in case ...

  1. javascript pass operator as parameter
  2. javascript pass operator to function
  3. javascript pass operator
  4. js pass operator as argument