0

Currently when the user selects an item from the DDL, the Id will be set to my model vm.Blah.Id

<div class="col-md-4">
    <label for="Blah">Blah blah</label>
    <select class="form-control" id="blah"  ng-change="vm.LoadBlahs()" ng-model="vm.Blah.Id">
        <option value="">Select some Blah</option>
        <option ng-repeat="m in vm.BlahList" value="{{m.BlahId}}">{{m.Name}}</option>
    </select>
</div>

When a DDL item is selected, I need to do this somehow:

vm.Blah.Id = m.BlahId;
vm.OtherBlah.SectionId = m.SectionId;

How can I update 2 things like that?

I'm on version 1.5.8

cool breeze
  • 4,461
  • 5
  • 38
  • 67
  • Why would you need to manually set `vm.Blah.Id = m.BlahId`. That is what happens by default when you select an item. – Pop-A-Stash Feb 16 '18 at 20:01

1 Answers1

0

You may have to re-work some of your code but a possible solution would be:

  1. Change ng-model to be a new variable that holds the selected item.

  2. Pass the ng-model (in your case m) as an argument to the ng-change function (See https://stackoverflow.com/a/22017098/1729686 for how to do this).

  3. Update the things in the ng-change function.

Liam
  • 1,041
  • 2
  • 17
  • 31