0

Please, someone there some idea why angular ui-bootstrap popover is not changing the model in scope?

<button popover-placement="right" 
        uib-popover-template="'myPopoverTemplate.html'"
        type="button" 
        class="btn btn-default">Click me!</button>

....

<script type="text/ng-template" id="myPopoverTemplate.html">
    <div class="form-group">
        <label>Date:</label>
        <p class="input-group">
            <input type="text" 
            class="form-control" 
            ng-model="dataClonada" 
            datepicker-options="dateOptionsClone" 
            uib-datepicker-popup="{{formats[5]}}" 
            is-open="popup3"
            readonly="true"/>
            <span class="input-group-btn">
            <button type="button" class="btn btn-default" ng-click="popup3=true"><i class="glyphicon glyphicon-calendar"></i></button>
            </span>
        </p>
        <button class="btn btn-success" ng-click="show()">show value</button>
    </div>
</script>

I did one simple plunker to show the situation. https://plnkr.co/edit/ebYWI8hP0xtOboY2v37Z?p=preview

0

2 Answers 2

1

You need to change

ng-model="dataClonada" 

to

ng-model="$parent.variable"

The directive (apparently) is creating a new child scope, so you need to use $parent to access the parent scope and access it's values (where variable resides).

Fixed plnkr

Sign up to request clarification or add additional context in comments.

1 Comment

Thaaaaaaaaaaaanks
1

For some reason for me it worked with double parent:

ng-model="$parent.$parent.variable"

Can be, because the popover was inside of a repeater?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.