简体   繁体   中英

Display models of text-angulars

I'm displaying two text-angular WYSIWYG fields in ng-repeat like so

<div data-ng-repeat="n in langInput.values" class="sell__description-container">
    <h2 class="sell__heading-secondary">
        Opis w języku: {{ n.selected }}
    </h2>
    <div text-angular="text-angular"
         name="htmlcontent_{{n.id}}_{{ n.selected }}"
         data-ng-model="descriptionHtml[$index]"
         class="sell__text-editor"
         required>
    </div>
    {{ descriptionHtml[$index] }}

And just below field I'm showing its model and it's working correctly. It shows text with all this tags which I chose in editor.

But 200 lines below I have something like summary and I want to display this model one more time in other ng-repeat loop:

<tr data-ng-repeat="n in langInput.values">
    <td>Opis ({{ n.selected }})</td>
    <td>
        {{ descriptionHtml[$index] }}
        <br>
        {{ $index }}
    </td>
</tr>

And here it is not showing description value. Althought $index is indeed 0 and 1 like above.. Why is that? How to fix?


At the moment I just want to make it work. Later on I'll not display it as a string in td but I'll pass this model as a string to function which will open bootstrap modal window in which I'll bind this string as html with ng-bind-html so it will be something like preview.

I found problem. I copied code from textangular docs and it has its own controller so my controller structure was like

<div ng-controller="external">
    <div ng-controller="textEditor">
        here i have ng-repeat and here i'm also displaying content of editor
    </div>
    here i tried to ng-repeat over it again
</div>

So in textEditor ctrl it was in right scope and it display correctly. I need to pass this value from child scope(textEditor) to parent scope(external).


Declaring $scope.descriptionHtml in parent controller solve the issue since child controller inherit scope and when I modify it in child then also parent is refreshed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM