从ngDialog返回值

时间:2017-09-08 14:50:40

标签: javascript angularjs ng-dialog

我正在使用ngDialog。出于某种原因,当我单击“关闭”时,closePromise数据参数不会返回"空缺"而对象返回的值是未定义的。

请告知我如何从对话框中将值返回给我的呼叫控制器。以下是我的代码:

<script type="text/ng-template" id="firstDialogId">
<div class="ngdialog-message">

    <h3>Pick a School</h3>
    <div class="form-group">
        <md-input-container class="md-block" >
            <md-select ng-model="Vacancy" placeholder="Select a Vacancy" id="Md-select2" name="vacancy2" >
                <md-option ng-value="vac" ng-repeat="vac in vacancylist" >{{vac.JobTitle}}</md-option>
            </md-select>
        </md-input-container>
    </div>
</div>

<div class="ngdialog-buttons">
    <button type="button" class="ngdialog-button ngdialog-button-primary" ng-click="closeThisDialog(Vacancy)">Ok</button>
</div>

$scope.clickToOpen = function () {
var dialog =  ngDialog.open({
        template: 'firstDialogId',
        className: 'ngdialog-theme-default',
        showClose: false,
        closeByEscape: false,
        width: '40%',
        closeByDocument: false,
        //data: { parentDialogModel: $scope.vacancylist }
    scope: $scope
}).closePromise.then(function (data) {
    if (data.value && data.value != '$document') {
        notification.show('success', 'Password was updated.');
    }
    else {
        notification.show('info', 'Password was not updated.');
    }

    return true;
});

1 个答案:

答案 0 :(得分:0)

我错过了以下的value属性:

   <button type="button" class="ngdialog-button ngdialog-button-primary" value="OK" ng-click="closeThisDialog(Vacancy)">Ok</button>