Mihai Gota Mihai Gota - 1 year ago 55
AngularJS Question

How to access in controller an angular model inside another model?

Every organization has multiple channels. Foreach organization, I display a multiple select box with the channels as options.

<div class="col-sm-9">
<div class="row">
<div class="col-sm-4" ng-repeat="orgModel in selectedOrganizations.selectedOrganizations">
<div class="box">
<div class="box-header"><h3>{{orgModel.name}}</h3></div>
<div class="box-divider m-a-0"></div>
<ul class="list no-border p-b">
<li class="list-item">
<div class="list-body">
<select multiple name="singleSelect" class="form-control input-c" id="singleSelect" ng-model="org.selectedChannels" ng-options="channel.name for channel in orgModel.channels" ng-show="item.editing">

Where and how I can access the
in the controller?

Answer Source

In order to assign selected channels to each organization you must use ng-repeat variable in ng-model of select element.


After that, you can access selected channels of each organization by index of organization:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download