javascript - 从 ngDialog 返回值

标签 javascript angularjs ng-dialog

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

请告知如何将值从我的对话框返回到我的调用 Controller 。下面是我的代码:

<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;
});

最佳答案

我缺少下面的值属性:

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

关于javascript - 从 ngDialog 返回值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46119212/

相关文章:

javascript - 销毁在 ngDialog 模态中启动的 AngularJS $interval

javascript - Marionette 应用程序未启动,并且没有错误!什么地方出了错?

javascript - 使用纯 JS 在 jQuery 中像 wrap() 函数一样包装元素

javascript - AngularJS 和 map API : stop prompting for computer's location

javascript - 在 Jasmine 中 mock Angular $元素

javascript - AngularJS 验证和 promise

angularjs - 自动关闭 ngDialog

php - 将字符串变量从 php 传递到 JS 函数

javascript - 滚动 anchor 链接上的主动导航

html - 我们如何删除 Angular js中的方括号[]和双引号 ""?