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.

Community
  • 1
  • 1
Angular Learner
  • 390
  • 4
  • 16
  • 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`? – Mark C. Nov 12 '15 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. – Angular Learner Nov 12 '15 at 14:01
  • Is there a reason you aren't using `repeat` on the `users` array? – Mark C. Nov 12 '15 at 14:05
  • @MarkC. In the html userId has users Array in it, we are doing repeat on users array. – Angular Learner Nov 12 '15 at 14:12
  • @MarkC. Sorry for the confusion I have edit my question now, please let me know if there's any thing still to be done. – Angular Learner Nov 12 '15 at 14:13
  • can you explain expected behavior? and expected result – Grundy Nov 12 '15 at 14:16
  • @Grundy We need to bind both firstname and lastname to the div element. Actually I need to send the firstname and lastname to the server as a string to get results of a particular user. Let me know if i am not clear – Angular Learner Nov 12 '15 at 14:28
  • it would be great if you can provide plunkr what you have with comment what you need – Grundy Nov 12 '15 at 14:33
  • 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 – Grundy Nov 12 '15 at 14:39
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/95016/discussion-between-grundy-and-amruth-rao). – Grundy Nov 13 '15 at 08:15
  • @Grundy Thanks I have followed your suggestion and now we are passing the whole object in to the user and calling the required one. once again thanks man..!! – Angular Learner Nov 13 '15 at 09:59

0 Answers0