Saturday, 15 June 2013

angularjs - Get selected item with ng-options -


There is an array with my attributes and I am trying to choose a certain load on the load.

Each feature has an array of object objects, objects and attributes. I want to select the attribute value with

I selected = true

I / {{"attribute": {"edit": {"id": 56, {"Id": 5, "typeName": "list"}, "attribute value": ["name": "helium", "type-edit": 5, "viewtuusers": true}, "type" 56, "value": 56, "value": 56, "value": "legius", "selected": true}, {"id": 110, "attribute ID": 56, "value": "Dakoke "," Selected ": incorrect}]," value text ": zero}]} $ $ scope.changeValue = function change value (attribute, value) {warning (JSON.stringify ({" attributeID ": attribute.attribute.id , "Type": Attribut E.type.typeName, "value": value.id}));};});

Here is my HTML code:

  & lt; Div ng-repeat = "profile data in attribute" & gt; & Lt; Ng-change = "changeValue (attribute, attributeValue)" ng-option = "attribute.attributeValues" item in the form of item.value as item.id "ng-model =" attributeValue.id "> gt; & Lt; / Select & gt; & Lt; / Div & gt;  

P> I do not know that this is the best solution to your problem, but it works.

I only want to create a function to search the selected value as a true. After finding that value, I set the radius model as the property value. Then I called that ceremony immediately afterwards.

  $ scope.selectChosen = function selectChosen () {var attrVals = $ scope.profile data. Features [0] .attributeValues; For (var i = 0; i & lt; attrVals.length; i ++) {if (attribute [i] .chosen) {$ scope.attributeValue = attrvals [i]; break; }}}; $ Scope.selectChosen ();   

The complete plunker is:

No comments:

Post a Comment