Angular-ui模态返回值

时间:2014-05-27 21:34:16

标签: angularjs modal-dialog angular-ui

我正在使用Angular-ui模态实例,我正在尝试获取返回值,但由于某种原因,绑定无法正常工作

var openNewAlbum = function() {

            var modal = $modal.open({
                templateUrl :'/app/modals/NewAlbumModal.html',
                controller  : function($scope, $modalInstance) {

                    $scope.albumTitle;

                    $scope.cancel = function() {
                        $modalInstance.dismiss('cancel');
                    };

                    $scope.accept = function() {
                        $modalInstance.close($scope.albumTitle);
                    }

                },
                keyboard: false,
                backdrop: 'static'
            });

            return modal;

        }

这是在控制器中:

$scope.newAlbum = function() {

            var modalInstance = ModalService.openNewAlbum();

            modalInstance.result.then(function(response) {

                console.log(response);

            });

        }

记录的var响应是我在Modal的Controller中分配给它的任何内容,而不是在输入中传递的内容

这是模态模板:

<div style="padding:6px">

    <div class="modal-body" style="font-weigth:bold;font-size:18px">

        <label for="">Nombre del Album</label>
        <input class="form-control" type="text" ng-model="albumTitle">
        {{albumTitle}}
        <br>

    </div>  

    <button class="btn btn-danger" ng-click="cancel()" >Cancelar</button>
    <button class="btn btn-primary pull-right" ng-click="accept()">Aceptar</button>

</div>

检查{{albumTitle}}时我看不到它发生了变化,但是当我点击“接受”时,返回值为“......”(分配给$ scope.albumTitle =''的值;)

0 个答案:

没有答案