0

We are using ui-select for the input boxes in our application.Please find below issue which we are facing.

<ui-select-choices repeat="user.firstname as user in users"  refresh="pvm.peopleSuggest($event, $select.search, 'userId')" refresh-delay="200" >
                    <div>{{user.firstname}}&nbsp;{{ user.lastname}}</div>
                </ui-select-choices>

In the above html you can see we need firstname and lastname of an object to bind to ng-model. I have gone through this link angular- ui-select - how to bind object property to ng-model as this one tells about how to bind single property to an object, but we need multi property to bind to ng-model.

This is my json data :

{
  "p_err_code":"success",
  "count":1,
  "users": [
   {"objectType":"user","user_id":"emea\\gaurapan","firstname":"Pandey","lastname":"Gaurav","designation":"External","status":"disabled","imagename":" ","type":"NONE"},

{"objectType":"user","user_id":"sdf\\sdf","firstname":"sdf","lastname":"rtrty","designation":"External","status":"disabled","imagename":" ","type":"NONE"},

  ]

}

This is my sample json

let me know if my question is unclear.

11
  • Can you provide an example of your json data set? I am wondering why pvm.peopleSearch.userId would have an array of users in it, and why you aren't just repeating each user instead of each user.firstname? Commented Nov 12, 2015 at 13:42
  • @MarkC. I have added my json now in the question. pvm.peopleSearch.userId takes a string with both firstname and lastname concatenated. Commented Nov 12, 2015 at 14:01
  • Is there a reason you aren't using repeat on the users array? Commented Nov 12, 2015 at 14:05
  • @MarkC. In the html userId has users Array in it, we are doing repeat on users array. Commented Nov 12, 2015 at 14:12
  • 1
    i think you a bit confusing: ng-model bind full selected object, in your case it would be user object, so you can get from it any property what you want Commented Nov 12, 2015 at 14:39

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.