S
S
Serg Sniffer2016-02-02 18:49:59
Angular
Serg Sniffer, 2016-02-02 18:49:59

How to pass ng-switch value to ng-include?

There are 2 html documents:
first-doc.html

<div class="first-doc">
  <select ng-model="selection">
      <option value="1">Первый</option>
      <option value="2">Второй</option>
  </select>
</div>

second-doc.html
<div class="second-doc">
  <select ng-model="selection" ng-switch="selection">
      <div ng-switch-when="1">первый вариант</div>
      <div ng-switch-when="2">второй вариант</div>
      <div ng-switch-default>ничего не выбрано</div>
  </select>
</div>

These documents are included in the file:
<div class="wrapper">
     <div ng-include="first-doc.html"></div>
     <div ng-include="second-doc.html"></div>
</div>

The question is: how to make ng-switch determine the value from select'a in another ng-include?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lega, 2016-02-02
@sniffer

Create an object in top scope and store variables in it, use "dotted" variable name, "data.selection"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question