1

After my get request i get

$scope.variables = response.data;

my select is:

<select name="varSelect" id="varSelect" ng-model="wid.adapter">
            <option ng-repeat="variable in variables" value="{{variable.id}}">{{variable.name}}</option>
</select>

after that i have two input text fields

<input type="text" ng-model="wid.url" />
<input type="text" ng-model="wid.name" />

On button click i want to post wid

$http.post(some_url, $scope.wid).then(function (response) {
            console.log(response);
});

My problem is that i dont get the object variable in wid.adapter. I gog the id. How to modify my code to get the variable instead of id?

1 Answer 1

3

use the variable as the value not the id

and use the ng-option attribute on the select to bind it properly

<select name="varSelect" id="varSelect" ng-model="wid.adapter"
    ng-options="variable.name for variable in variables">
    </select>
Sign up to request clarification or add additional context in comments.

5 Comments

when i use variable instead of id i got json string.
the second part is working, with ng option. tnx a lot
the second one uses angular binding instead of typical html behavior
@M B how can I set placeholder at position one. First time input select is empty. I want to put some value in select.
@VSH set the ng-model to the value you want to select

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.