Frontend - parent element accessing ng-reapeat inner element
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-05-15 16:50:04
0
1
682
 <ul class="msg-common" ng-show="showAnswer">
        <li ng-repeat="mn in m.fastReply" ng-click="sh = mn.content "> {{mn.content}}</li>
      </ul>
      <p class="answer" ng-show="showAnswer">
        <textarea >{{sh}}</textarea>
      </p>

As shown above, implement sh to access mn.content to implement changes in textarea!

曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(1)
漂亮男人

The least modified solution is to use $parent.sh = mn.content

http://jsfiddle.net/Gerhut/umuakzr3/

Because $parent is not recommended to be used, the recommended solution is to add a function similar to setSh in the parent scope and call it directly in the child scopesetSh(mn.content).

http://jsfiddle.net/Gerhut/umuakzr3/1/

If you use Angular version 1.2 or above, you can also use the Controller as method to directly obtain the reference of the parent Controller.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template