1
<div class="task-manager_block" ng-controller="ToDoCtrl">
    <div class="form_block clearfix">
        <form name="addToDo">
        <input class="add-input" placeholder="I need to..." type="text" name="inputToDo" ng-model="formTodoText" ng-model-instant ng-minlenght ng-minlength="5" ng-maxlength="40" ng-required="true"/>
        <button class="add-btn" ng-click="addTodo()" ng-disabled="! addToDo.inputToDo.$valid "><h2>Add</h2></button>
      </form>
    </div>
    <div class="tasks_block" ng-controller="DatepickerPopupCtrl">
        <div class="task_block col-md-3" ng-repeat="todo in todos">
            <div class="text_block">
                <p class="input-group">
          <input type="text" class="form-control" uib-datepicker-popup="{{format}}" ng-model="dt" is-open="popup1.opened" datepicker-options="dateOptions" ng-required="true" close-text="Close" alt-input-formats="altInputFormats" />
          <span class="input-group-btn">
            <button type="button" class="btn btn-default" ng-click="open1()"><i class="glyphicon glyphicon-calendar"></i></button>
          </span>
        </p>
                <p>{{todo.text}}</p>
            </div>
        </div>      
    </div>
</div>

How can I open a single popup that I clicked on because now all of them are instantly opened independently of what I clicked.

0

1 Answer 1

1

This happens due to all the datepickers inside ng-repeat reference the same variable to check open state.

See this.

is-open="popup1.opened"

You will have to manage this state in a separate object. For example,

In controller declare a empty object

let datePickersStat = {};

then in your HTML, you can use anything as object key as long as it's unique.

is-open="datePickersStat[todo.id]"

Hope that helps.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.