Return value back from ngDialog

894 views Asked by At

I am using ngDialog. For some reason when I click Close, the closePromise data parameter doesnt return the "Vacancy" object instead the returned value is undefined.

Please advise How do I get the value back from my dialog to my calling controller. Below is my code:

<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

There are 1 answers

0
user8427641 On BEST ANSWER

I was missing the value attribute below:

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