Mihai Gota Mihai Gota - 6 months ago 25
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?


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: