Load modal with data. (doubts)


#1

Hello guys, I’m new to the Ionic and I have a simple doubt.

I created a modal rececer to a record … in the end I saved this information and so far so good.

But if I want to edit this data, how do I open a modal already with information consisting for me to edit and save changes?

I thank the attention … =D


#2

Just set the model data you are using in the modal. If you have an input using ng-model=“email”, just set $scope.email = "whaterever@value.com" in your controller. It will be there when you open the modal!

Robert


#3

I understand, but look:

In my controller:

$scope.item = {};

In my modal:

  <script id="newTask.html" type="text/ng-template">
      <ion-model-view>
        <ion-header-bar class="bar bar-header bar-dark">
          <h1 class="title">New Task</h1>
          <button class="button button-icon icon ion-arrow-return-left" ng-click="closeModal()"></button>
        </ion-header-bar>
        <ion-content class="padding">
          <div class="list">
            <label class="item item-input">
              <i class="icon ion-asterisk placeholder-icon"></i>
              <input ng-model="item.n" type="text" placeholder="Title">
            </label>
            <label class="item item-input">
              <i class="icon ion-asterisk placeholder-icon"></i>
              <textarea ng-model="item.det" placeholder="Description"></textarea>
            </label>
            <label class="item item-input">
              <i class="icon ion-asterisk placeholder-icon"></i>
              <input ng-model="item.dateTime" type="datetime-local" placeholder="Date">
            </label>
            <button class="button button-full button-dark" ng-click = "onItemAdd(nTask)">Create</button>
          </div>
        </ion-content>
      </ion-model-view>
    </script>

that’s right?


#4

You havent defined the objects within $scope.item. There is no item.n or item.det or item.dateTime.

$scope.item = {n: “”, det: “”, dateTime: “”};