属性 'then' 在类型 'DialogRef<TwoButtonPreset>' 上不存在 'DialogRef<TwoButtonPreset>'.ts(2339)
Property 'then' does not exist on type 'DialogRef<TwoButtonPreset>'.ts(2339)
嗨,我正在尝试 运行 从 angular2-modal 更新到 ngx-modialog
后 Angular 6 上的这段代码
this.modal.confirm()
.showClose(true)
.title(this.translator.instant('common.message.confirm.delete'))
.keyboard(27)
.okBtn(this.translator.instant('common.text.yes'))
.cancelBtn(this.translator.instant('common.text.no'))
.message("<h5>" + this.translator.instant('common.message.confirm.deleteAll') + "</h5>")
.open()
.then(( d ) => d.result
.then(( r ) => {...});
但编译后我得到这个错误:
Property 'then' does not exist on type 'DialogRef<TwoButtonPreset>'.ts(2339)
我试过了,但同样的错误
...
dialog: DialogRef<TwoButtonPreset>;
...
let dialog = this.modal.confirm() .showClose(true)
.title(this.translator.instant('common.message.confirm.delete'))
.keyboard(27)
.okBtn(this.translator.instant('common.text.yes'))
.cancelBtn(this.translator.instant('common.text.no'))
.message("<h5>" + this.translator.instant('common.message.confirm.deleteAll') + "</h5>")
.open()
.then(( d ) => d.result
...
我也试过了,但是得到 ; expected
this.modal.confirm()
.showClose(true)
.title(this.translator.instant('common.message.confirm.delete'))
.keyboard(27)
.okBtn(this.translator.instant('common.text.yes'))
.cancelBtn(this.translator.instant('common.text.no'))
.message("<h5>" + this.translator.instant('common.message.confirm.deleteAll') + "</h5>")
.open()
.result => {...};
这是我的 package.json:
{
"name": "frontend6",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^6.1.0",
"@angular/common": "^6.1.0",
"@angular/compiler": "^6.1.0",
"@angular/core": "^6.1.0",
"@angular/forms": "^6.1.0",
"@angular/http": "^6.1.0",
"@angular/platform-browser": "^6.1.0",
"@angular/platform-browser-dynamic": "^6.1.0",
"@angular/router": "^6.1.0",
"@ngx-translate/core": "^12.1.2",
"@ngx-translate/http-loader": "^4.0.0",
"@types/alertify": "^0.3.29",
"@types/file-saver": "0.0.1",
"@types/highcharts": "^5.0.25",
"@types/jquery": "2.0.47",
"@types/openlayers": "4.6.9",
"ag-grid": "7.1.0",
"ag-grid-ng2": "7.1.2",
"angular-tree-component": "^3.7.3",
"angular2-google-maps": "0.17.0",
"angular2-infinite-scroll": "^0.3.4",
"angular2-text-mask": "2.1.0",
"angular2-toaster": "^8.0.0",
"angular2-tree-component": "2.0.0",
"animate.css": "^3.7.2",
"bootstrap": "3.3.7",
"chart.js": "^2.7.3",
"chroma-js": "^1.3.7",
"codemirror": "5.22.0",
"core-js": "^2.5.4",
"easy-pie-chart": "2.1.7",
"file-saver": "1.3.3",
"flot": "0.8.0-alpha",
"font-awesome": "4.7.0",
"fullcalendar": "3.1.0",
"highcharts": "^6.2.0",
"highcharts-stock": "^0.1.7",
"jqcloud2": "2.0.2",
"jquery": "^3.5.1",
"jquery-slimscroll": "1.3.8",
"jquery-sparkline": "2.4.0",
"jquery.browser": "0.1.0",
"jquery.flot.tooltip": "0.9.0",
"jspdf": "1.3.5",
"jspdf-autotable": "2.3.2",
"lodash": "^4.17.15",
"modernizr": "^3.11.1",
"moment": "^2.25.3",
"mydatepicker": "1.10.2",
"ng2-bootstrap": "1.1.16-11",
"ng2-charts": "^1.6.0",
"ng2-data-table": "1.0.0",
"ng2-dnd": "2.1.1",
"ng2-file-upload": "1.1.4-2",
"ng2-img-cropper": "0.7.7",
"ng2-select": "1.1.2",
"ng2-table": "1.3.2",
"ng2-tag-input": "0.7.0",
"ng2-validation": "3.1.3",
"ngx-modialog": "^5.0.1",
"openlayers": "3.20.1",
"rxjs": "~6.2.0",
"rxjs-tslint": "^0.1.8",
"screenfull": "3.0.2",
"simple-line-icons": "2.4.1",
"spinkit": "1.2.5",
"summernote": "0.8.2",
"ts-helpers": "1.1.1",
"weather-icons": "1.3.2",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-builders/jest": "^7.2.3",
"@angular-devkit/build-angular": "~0.8.0",
"@angular/cli": "~6.2.9",
"@angular/compiler-cli": "^6.1.0",
"@angular/language-service": "^6.1.0",
"@types/codemirror": "0.0.37",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/moment": "2.13.0",
"@types/node": "~8.9.4",
"codelyzer": "~4.3.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-cli": "1.0.1",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-read-json": "1.1.0",
"karma-remap-istanbul": "0.2.1",
"loaders.css": "0.1.2",
"napa": "2.3.0",
"protractor": "4.0.13",
"ts-node": "1.2.1",
"tslint": "4.0.2",
"typescript": "^2.4.2",
"webdriver-manager": "10.2.5",
"webpack": "^4.11.1",
"webpack-dev-server": "2.1.0-beta.9"
}
}
基础应用程序在 Angular 2 我可以将其升级到 Angular 4 现在我要 Angular 6
我猜 open()
不是 return Promise。尝试像这样添加 .result
:
...
.open().result => alert(`The result is: ${result}`) );
...
(这是针对 v4 的)
您需要引用 dialogRef 本身,
dialogRef.result
.then( result => alert(`The result is: ${result}`) );
我通过在 then
之前添加 result
来修复它:
...
this.modal.confirm().showClose(true)
.title(this.translator.instant('common.message.confirm.delete'))
.keyboard(27)
.okBtn(this.translator.instant('common.text.yes'))
.cancelBtn(this.translator.instant('common.text.no'))
.message("<h5>" + this.translator.instant('common.message.confirm.deleteAll') + "</h5>")
.open()
.result
.then(( d ) => d.result
...
嗨,我正在尝试 运行 从 angular2-modal 更新到 ngx-modialog
后 Angular 6 上的这段代码this.modal.confirm()
.showClose(true)
.title(this.translator.instant('common.message.confirm.delete'))
.keyboard(27)
.okBtn(this.translator.instant('common.text.yes'))
.cancelBtn(this.translator.instant('common.text.no'))
.message("<h5>" + this.translator.instant('common.message.confirm.deleteAll') + "</h5>")
.open()
.then(( d ) => d.result
.then(( r ) => {...});
但编译后我得到这个错误:
Property 'then' does not exist on type 'DialogRef<TwoButtonPreset>'.ts(2339)
我试过了,但同样的错误
...
dialog: DialogRef<TwoButtonPreset>;
...
let dialog = this.modal.confirm() .showClose(true)
.title(this.translator.instant('common.message.confirm.delete'))
.keyboard(27)
.okBtn(this.translator.instant('common.text.yes'))
.cancelBtn(this.translator.instant('common.text.no'))
.message("<h5>" + this.translator.instant('common.message.confirm.deleteAll') + "</h5>")
.open()
.then(( d ) => d.result
...
我也试过了,但是得到 ; expected
this.modal.confirm()
.showClose(true)
.title(this.translator.instant('common.message.confirm.delete'))
.keyboard(27)
.okBtn(this.translator.instant('common.text.yes'))
.cancelBtn(this.translator.instant('common.text.no'))
.message("<h5>" + this.translator.instant('common.message.confirm.deleteAll') + "</h5>")
.open()
.result => {...};
这是我的 package.json:
{
"name": "frontend6",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^6.1.0",
"@angular/common": "^6.1.0",
"@angular/compiler": "^6.1.0",
"@angular/core": "^6.1.0",
"@angular/forms": "^6.1.0",
"@angular/http": "^6.1.0",
"@angular/platform-browser": "^6.1.0",
"@angular/platform-browser-dynamic": "^6.1.0",
"@angular/router": "^6.1.0",
"@ngx-translate/core": "^12.1.2",
"@ngx-translate/http-loader": "^4.0.0",
"@types/alertify": "^0.3.29",
"@types/file-saver": "0.0.1",
"@types/highcharts": "^5.0.25",
"@types/jquery": "2.0.47",
"@types/openlayers": "4.6.9",
"ag-grid": "7.1.0",
"ag-grid-ng2": "7.1.2",
"angular-tree-component": "^3.7.3",
"angular2-google-maps": "0.17.0",
"angular2-infinite-scroll": "^0.3.4",
"angular2-text-mask": "2.1.0",
"angular2-toaster": "^8.0.0",
"angular2-tree-component": "2.0.0",
"animate.css": "^3.7.2",
"bootstrap": "3.3.7",
"chart.js": "^2.7.3",
"chroma-js": "^1.3.7",
"codemirror": "5.22.0",
"core-js": "^2.5.4",
"easy-pie-chart": "2.1.7",
"file-saver": "1.3.3",
"flot": "0.8.0-alpha",
"font-awesome": "4.7.0",
"fullcalendar": "3.1.0",
"highcharts": "^6.2.0",
"highcharts-stock": "^0.1.7",
"jqcloud2": "2.0.2",
"jquery": "^3.5.1",
"jquery-slimscroll": "1.3.8",
"jquery-sparkline": "2.4.0",
"jquery.browser": "0.1.0",
"jquery.flot.tooltip": "0.9.0",
"jspdf": "1.3.5",
"jspdf-autotable": "2.3.2",
"lodash": "^4.17.15",
"modernizr": "^3.11.1",
"moment": "^2.25.3",
"mydatepicker": "1.10.2",
"ng2-bootstrap": "1.1.16-11",
"ng2-charts": "^1.6.0",
"ng2-data-table": "1.0.0",
"ng2-dnd": "2.1.1",
"ng2-file-upload": "1.1.4-2",
"ng2-img-cropper": "0.7.7",
"ng2-select": "1.1.2",
"ng2-table": "1.3.2",
"ng2-tag-input": "0.7.0",
"ng2-validation": "3.1.3",
"ngx-modialog": "^5.0.1",
"openlayers": "3.20.1",
"rxjs": "~6.2.0",
"rxjs-tslint": "^0.1.8",
"screenfull": "3.0.2",
"simple-line-icons": "2.4.1",
"spinkit": "1.2.5",
"summernote": "0.8.2",
"ts-helpers": "1.1.1",
"weather-icons": "1.3.2",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-builders/jest": "^7.2.3",
"@angular-devkit/build-angular": "~0.8.0",
"@angular/cli": "~6.2.9",
"@angular/compiler-cli": "^6.1.0",
"@angular/language-service": "^6.1.0",
"@types/codemirror": "0.0.37",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/moment": "2.13.0",
"@types/node": "~8.9.4",
"codelyzer": "~4.3.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-cli": "1.0.1",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-read-json": "1.1.0",
"karma-remap-istanbul": "0.2.1",
"loaders.css": "0.1.2",
"napa": "2.3.0",
"protractor": "4.0.13",
"ts-node": "1.2.1",
"tslint": "4.0.2",
"typescript": "^2.4.2",
"webdriver-manager": "10.2.5",
"webpack": "^4.11.1",
"webpack-dev-server": "2.1.0-beta.9"
}
}
基础应用程序在 Angular 2 我可以将其升级到 Angular 4 现在我要 Angular 6
我猜 open()
不是 return Promise。尝试像这样添加 .result
:
...
.open().result => alert(`The result is: ${result}`) );
...
(这是针对 v4 的)
您需要引用 dialogRef 本身,
dialogRef.result
.then( result => alert(`The result is: ${result}`) );
我通过在 then
之前添加 result
来修复它:
...
this.modal.confirm().showClose(true)
.title(this.translator.instant('common.message.confirm.delete'))
.keyboard(27)
.okBtn(this.translator.instant('common.text.yes'))
.cancelBtn(this.translator.instant('common.text.no'))
.message("<h5>" + this.translator.instant('common.message.confirm.deleteAll') + "</h5>")
.open()
.result
.then(( d ) => d.result
...