I have a question about setting up a NG-model in combination with a select widget and fingers (watch this video :)
What I would like to do, is to set the recipient on some values which will be selected from the first time. For example HTML and JS (by video)
& Lt; Select data-placeholder = "select a recipient" multiple class = "span4-chzn-select" selected ng-model = "recipient" ng-option = "name list for recipient recipient in recipient" gt; & Lt; / Select & gt; & Lt; P ng-repeat = "recipient in recipient" & gt; & Lt; Strong & gt; {{Recipient .name}} & lt; / Strong> & Lt; / P & gt; and JS in the controller
$ scope.recipientsList = []; $ Scope.recipients = []; $ Scope.fetchRecipients = function () {$ http.get ($ scope.url). Then {function (result) {$ scope.recipientsList = [{"id": 0, "name": "recipient 0"}, {"id": 1, "name": "recipient1"}, {"id "": "Name": "recipient 4"}, {"id": 3, "name": "recipient 3"}, "": "name": "name": {"recipient 4"}, {" Id ":" name ":" name ":" recipient "5," name ": {" id ": 6," name ":" recipient 6 "}," name ": {" id ": 7," name ":" recipient 7 {"Id": 8, "name": "recipient 8"}, {"id": 9, "name": "recipient 9"}, {"id": 10, "name": "recipient 10 "}] $ scope.recipients = [{" id ": 0," name ":" recipient 0 "}, {" id ": 1," name ":" recipient 1 "}];}); } $ Scope.fetchRecipients (); I tried some combinations, but the values in the menu are not predefined, although they are stored in recipients, because they are visible below the menu. You can see this example here:
Thank you for your ansers.
Matte
Angliagio ngOptions attribute with a given array of data sources Selects one element. In your case, there are some objects in the list of recipients. However, the elements you want to choose are not present in the list due to the inequality of the object, although they are similar. Meaning Recipient List: {"id": 0, "name": "recipient 0"} is not equal to recipients: {"id": 0, "name": "recipient 0"} (you have JS console). The angled inventory does not find the element and therefore does not choose it.
This works the modified Bela: The only difference in this case is your recipient definition:
$ Scope.recipients = [$ scope.recipientsList [0], $ Scope.recipientsList [1]] In this case you have a list and the selected value can only come from that list.
An alternative to this approach which you will use if you want to maintain two lists, then select the selection as an initial type. In which case primitive equality always lives.
No comments:
Post a Comment