Angular-带模态范围

Angular-strap modal scope

我正在使用 angular-strap,特别是它的模式,我在编码时使用 this 样式。它是我控制器的一部分:

function parentController($scope, $routeParams, $location, $modal) {
    var vm = this;
    vm.message = '';
...

模态的html部分:

<div class="modal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header" ng-show="title">
                <button type="button" role="button" class="close" aria-label="Close" ng-click="$hide()"><span aria-hidden="true">&times;</span></button>
                <h1 class="modal-title" ng-bind="title"></h1>
            </div>
            <div class="modal-body" ng-bind-html="content">
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-success pull-left" ng-click="$hide();parentController.f1();" aria-label="Close">yes</button>
                <button type="button" class="btn btn-danger pull-left" ng-click="$hide();parentController.f2();" aria-label="Close">no</button>
            </div>
        </div>
    </div>
</div>

这是我在控制器中的模态定义:

var modalObject = {
                scope: $scope,
                templateUrl: 'path/to/modal.html',
                title: 'desc',
                content: '<p>enter description here</p> <textarea ng-model="parentController.message" class="form-control" rows="10"></textarea>',
                show: false
            };

$modal(modalObject);

现在,我将访问parentController 中的消息值。当我在 f2 函数中记录 vm.message 时,它原样是空的。访问它的解决方案是什么?

我最终通过从控制器中删除内容并将其手动添加到 html 代码中解决了这个问题。

var modalObject = {
                scope: $scope,
                templateUrl: 'path/to/modal.html',
                title: 'desc',
                show: false
            };

$modal(modalObject);

模态的html代码:

<div class="modal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header" ng-show="title">
                <button type="button" role="button" class="close" aria-label="Close" ng-click="$hide()"><span aria-hidden="true">&times;</span></button>
                <h1 class="modal-title" ng-bind="title"></h1>
            </div>
            <div class="modal-body">
                <p>enter description here</p>
                <textarea ng-model="parentController.message" class="form-control" rows="10"></textarea>
        </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-success pull-left" ng-click="$hide();parentController.f1();" aria-label="Close">yes</button>
                <button type="button" class="btn btn-danger pull-left" ng-click="$hide();parentController.f2();" aria-label="Close">no</button>
            </div>
        </div>
    </div>
</div>

所以,我的模型中有 textarea 的值