当我在模态中使用Angular-trix时绑定不起作用

时间:2016-05-29 16:30:07

标签: angularjs twitter-bootstrap

我正在使用angular-trix。 我启动了一个模态(bootstrap),但绑定不起作用。

如果我将绑定放在div中,我可以看到它被传递给模态但是对于angular-trix组件它不会出现。

我的代码是:

         $scope.editCommentDialog = function (comment) {
            var modalInstance = $modal.open({
                templateUrl: 'editCommentDialog.html',
                windowClass : 'edit-comment-modal-dialog',
                controller: function ($scope, $modalInstance, editedComment) {
                    $scope.editedComment = editedComment;

                    $scope.ok = function () {
                        $modalInstance.close(editedComment);
                    };

                    $scope.cancel = function () {
                        $modalInstance.dismiss('cancel');
                    };
                },
                resolve: {
                    editedComment: function () {
                       return { id : comment.id,  text : comment.text};
                    }
                }
            });

            modalInstance.result.then(function (editedComment) {
                $scope.editedComment = editedComment;
                $scope.updateComment();
            }, function () {
                $log.info('Modal dismissed at: ' + new Date());
            });
        };

<script type="text/ng-template" id="editCommentDialog.html">
<div class="modal-header">
    <h3>Edit</h3>
</div>
<div class="modal-body">
    <trix-editor angular-trix ng-model="editedComment.text" class="trix-content editable-trix-editor"></trix-editor>
   </div>
   <div class="modal-footer">
    <button class="btn btn-primary" ng-click="ok()">OK</button>
    <button class="btn btn-warning" ng-click="cancel()">Cancel</button>
</div>
</script>

1 个答案:

答案 0 :(得分:0)

<trix-editor angular-trix ng-model="editedComment.text" class="trix-content editable-trix-editor"></trix-editor>

在您的代码中添加ng-if =“ true”,这样现在看起来:

<trix-editor ng-if="true" angular-trix ng-model="editedComment.text" class="trix-content editable-trix-editor"></trix-editor>

它解决了问题