1

I have a very simple scenario and I wanted to use AngularJS for that. I am not able to get this one right.

I am retrieving data from database and directly writing it into the view inside dropdown. From their based on which item is selected, I want to populate the value into textbook.

So my code for it is as follows:

<select>
  <option selected="selected" disabled="disabled">dropdown</option>
  @foreach (System.Data.DataRow row in ViewBag.Template.Rows)
  {
    <option value="@row[1].ToString()">@row[0].ToString()</option>
  }
</select>
<textarea></textarea>

I am trying to achieve following:

whatever option user select, the corresponding value for the item be populated into text area.

Please suggest how can I achieve using AngularJS.

1 Answer 1

1

You should use ngModel directive for that, the same for both select and textarea:

<select ng-model="selectModel">
  <option selected="selected" disabled="disabled">dropdown</option>
  @foreach (System.Data.DataRow row in ViewBag.Template.Rows)
  {
    <option value="@row[1].ToString()">@row[0].ToString()</option>
  }
</select>
<textarea ng-model="selectModel"></textarea>

Demo: http://plnkr.co/edit/XOs6wUyqdr3ZlFtBq3RB?p=preview

Sign up to request clarification or add additional context in comments.

Comments

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.