0

我正在尝试打开一个对话框,用户可以在其中输入名称,然后在控制器上调用一个方法,传递对话框中的结果。

class MyController {

    constructor(public $scope, public $dialog) {
    }

    AddNew() {

        var t = '<form name="form" novalidate><div class="modal-header">' +
          '<h3>Nova mapa</h3>' +
          '</div>' +
          '<div class="modal-body">' +
          '<p>Name: <input ng-model="result" type="text" required/></p>' +
          '</div>' +
          '<div class="modal-footer">' +
          '<button ng-click="close()" class="btn btn-primary" >Close</button>' +
          '<button ng-click="close(result)" class="btn btn-primary" ng-disabled="form.$invalid">Save</button>' +
          '</div><form>';

        this.$scope.opts = {
            backdropClick: false,
            template: t,
            controller: 'AddNewDialog'
        };


        var d = this.$dialog.dialog(this.$scope.opts);
        d.open().then(function (result) {
            if (result) {
                // this does not work 
                this.AddNewInternal(result)
            }
        });
    }

    private AddNewInternal(description: string) {
        //logic here

    };
}

function AddNewDialog
    ($scope, dialog) {
    $scope.close = () => {
        $scope.close(undefined);
    }
    $scope.close = (result) => {
        dialog.close(result);
    };
}

我收到一个错误“对象不支持属性或方法'AddNewInternal'”有人可以帮我解决这个问题吗?谢谢

4

0 回答 0