角色,编辑文字

时间:2018-05-06 14:24:08

标签: angularjs

我用ng-repeat输出了10个项目。每个下面都有一个编辑按钮。单击时,调用该函数,该函数检测通常的模态引导窗口,我将其替换为文本:

$scope.stepEdit = function (index, text) {
  $("#myModal").modal({show: true});
  $scope.editText = text; 
};

在模态窗口中有一个" save"按钮,但我不明白如何保存该文本。想到ng-bind,但是,我再次理解如何在这里使用它

以下是这10个项目:

            <div class="list-group" id="steps">
                <hr>
                <div ng-repeat="desc in info.steps">
                    <a href="#" class="list-group-item list-group-item-action ng-binding ng-scope" id="steps">{{desc}}</a>

                    <div class="btn-group btn-group-toggle" data-toggle="buttons">
                        <label class="btn btn-secondary active" ng-click="stepEdit($index, desc)">
                            <i class="fa fa-pencil" aria-hidden="true"></i>
                        </label>
                        <label class="btn btn-secondary" ng-click="stepDelete(desc)">
                            <i class="fa fa-trash" aria-hidden="true"></i>
                        </label>
                    </div>
                </div>
            </div>

在这下面是模态:

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle"
         aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <textarea class="modal-body" ng-model="newText">{{editText}}</textarea>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                    <button type="button" class="btn btn-primary" ng-click="sendNewText">Save changes</button>
                </div>
            </div>
        </div>
    </div>

0 个答案:

没有答案