0

I have used ui select for my angularjs project

Country list

    [{
        "_id": "596dbedd7892ca3f3e331aca",
        "updatedAt": "2017-07-18T07:55:09.318Z",
        "createdAt": "2017-07-18T07:55:09.318Z",
        "countryName": "australia",
        "countryCode": "ABC",
        "countryCurrencyCode": "ABC",
        "countryCurrencySymbol": "*\r",
        "slug": "australia",
        "sortNo": 2,
        "createdBy": "57eb8bf7216c5a624b19a504",
        "modifiedBy": "57eb8bf7216c5a624b19a504",
        "version": "nil",
        "__v": 0,
        "isActive": true
    }, {
        "_id": "5972ed8dd470521889c468b9",
        "updatedAt": "2017-07-26T10:54:05.817Z",
        "createdAt": "2017-07-22T06:15:41.356Z",
        "countryName": "India",
        "countryCode": "IND",
        "countryCurrencyCode": "INR",
        "countryCurrencySymbol": "¥",
        "slug": "india",
        "sortNo": 4,
        "createdBy": "57eb8bf7216c5a624b19a504",
        "modifiedBy": "57eb8bf7216c5a624b19a504",
        "version": "nil",
        "__v": 0,
        "isActive": true
    }, {
        "_id": "5972ed8dd470521889c468ba",
        "updatedAt": "2017-07-22T06:18:08.309Z",
        "createdAt": "2017-07-22T06:15:41.365Z",
        "countryName": "unitede kingtom",
        "countryCode": "XYZ",
        "countryCurrencyCode": "XYZ",
        "countryCurrencySymbol": "#",
        "slug": "unitede-kingtom",
        "sortNo": 5,
        "createdBy": "57eb8bf7216c5a624b19a504",
        "modifiedBy": "57eb8bf7216c5a624b19a504",
        "version": "nil",
        "__v": 0,
        "isActive": true
    }, {
        "_id": "59786d52618a2b796c13593f",
        "updatedAt": "2017-07-26T10:22:10.957Z",
        "createdAt": "2017-07-26T10:22:10.957Z",
        "countryName": "QWEE",
        "countryCode": "WEWQ",
        "countryCurrencyCode": "ING",
        "countryCurrencySymbol": "€",
        "slug": "qwee",
        "sortNo": 7,
        "createdBy": "57eb8bf7216c5a624b19a504",
        "modifiedBy": "57eb8bf7216c5a624b19a504",
        "version": "nil",
        "__v": 0,
        "isActive": true
    }, {
        "_id": "597b0521e0d5ae36c3d4aadb",
        "updatedAt": "2017-07-28T09:42:39.755Z",
        "createdAt": "2017-07-28T09:34:25.959Z",
        "countryName": "india",
        "countryCode": "IND",
        "countryCurrencyCode": "AUS",
        "countryCurrencySymbol": "€",
        "slug": "india-SJ5XStOIZ",
        "sortNo": 10,
        "createdBy": "57eb8bf7216c5a624b19a504",
        "modifiedBy": "57eb8bf7216c5a624b19a504",
        "version": "nil",
        "__v": 0,
        "isActive": true
    }]

and in other UI select State list

[{
        "_id": "596dcfbfe25f9d4738bea7d9",
        "updatedAt": "2017-07-18T09:07:11.835Z",
        "createdAt": "2017-07-18T09:07:11.835Z",
        "countryId": "596dbedd7892ca3f3e331aca",
        "stateName": "south australia",
        "timezone": "58c6516abf49c40fce836a1b",
        "sortNo": 0,
        "createdBy": "57eb8bf7216c5a624b19a504",
        "version": "nil",
        "__v": 0,
        "isActive": true,
        "slug": "south-australia"
    }, {
        "_id": "596dcfbfe25f9d4738bea7db",
        "updatedAt": "2017-07-18T09:07:11.846Z",
        "createdAt": "2017-07-18T09:07:11.846Z",
        "countryId": "596dbedd7892ca3f3e331aca",
        "stateName": "western australia",
        "timezone": "58c64e1abf49c40fce836a1a",
        "sortNo": 2,
        "createdBy": "57eb8bf7216c5a624b19a504",
        "version": "nil",
        "__v": 0,
        "isActive": true,
        "slug": "western-australia"
    }, {
        "_id": "596dd0ede25f9d4738bea7dd",
        "updatedAt": "2017-07-18T09:12:13.161Z",
        "createdAt": "2017-07-18T09:12:13.161Z",
        "countryId": "596dbedd7892ca3f3e331aca",
        "stateName": "new south wales",
        "timezone": "58c64e1abf49c40fce836a1a",
        "sortNo": 4,
        "createdBy": "57eb8bf7216c5a624b19a504",
        "version": "nil",
        "__v": 0,
        "isActive": true,
        "slug": "new-south-wales"
    }, {
        "_id": "59786e36618a2b796c135941",
        "updatedAt": "2017-07-26T10:25:58.705Z",
        "createdAt": "2017-07-26T10:25:58.705Z",
        "countryId": "59786d8d618a2b796c135940",
        "stateName": "tets@123",
        "timezone": "58c64e1abf49c40fce836a1a",
        "sortNo": 5,
        "createdBy": "57eb8bf7216c5a624b19a504",
        "version": "nil",
        "__v": 0,
        "isActive": true,
        "slug": "tets123"
    }]

Here, I have two UI select. One is country and other one was state list. When user clicks on country list, state list have to filtered based on _id using angualrjs FILTER.

We can do normal select by using filter but, in UI select how to do that?

3
  • 1
    In order to achieve this you should fire a ng-change on your country ui-select and then filter the states according to the chosen country. Then use this filtered object in your state ui-select Commented Jul 28, 2017 at 12:45
  • 1
    Check this Commented Jul 28, 2017 at 12:46
  • @Durga this one is multiple select i want to do in single select Commented Jul 28, 2017 at 12:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.