Get element by id from inside a modal


#1

Hello. I’m struggling in getting an element from inside a modal scope.

This is my modal

<script id="_writtenNoteModal.html" type="text/ng-template">
    <ion-modal-view>
        <ion-header-bar class="bar-light">
            <div class="buttons">
                <button ng-click="saveNote()" class="button button-small button-clear button-dark">Save</button>
            </div>
            <h1 class="title">Written Note</h1>
            <div class="buttons">
                <button ng-click="closeWrittenNoteModal()" class="button button-small button-clear button-dark">Cancel</button>
            </div>
        </ion-header-bar>
        <ion-content class="padding">
            <div class="row">
                <div class="col">
                    <textarea id="writtenNote" placeholder="Write notes about this wine..." rows="7"></textarea>
                </div>
            </div>
        </ion-content>
    </ion-modal-view>
</script>

The modal is declared to $scope.writtenNoteModal

Now I’m trying to get the element like so:

$scope.writtenNoteModal.getElementById('writtenNote').value;

But it isn’t working. How can I get an element from inside a modal?


#2

… ähm the modalObject is no DomElement i think… it is a ionic-modalObject

For dom manipulating things you just can use angularjs directives… there your get the $scope, the $element as jqLite object and the attributes of that dom element.


#3

Ofcourse! How foolish of me. I have no idea why I was thinking it is a DomElement :smiley:

Thank-you for your help.