任何人都可以告诉我你是如何访问变量的,sweetalert2中的函数是目前我无法访问任何内容时会出现此错误。
TypeError:无法设置未定义的属性'wait'
我的代码
swal({
title: 'Editar '+ camponome,
input: 'text',
showCancelButton: true,
inputValue: campo,
}).then(function(text) {
if (text) {
swal({
title: 'Aviso ',
text: "Tem a certeza que deseja Editar",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
cancelButtonText:'Cancelar',
confirmButtonText: 'Sim Tenho '
}).then(function() {
this.wait=true;
})
}
})
更新ng2-sweetalert2错误
我按照npm安装了ng2-sweetalert2并给了我以下错误
GET http://localhost:3000/node_modules/ng2-sweetalert2/ 404 (Not Found)
Error: Error: XHR error (404 Not Found) loading http://localhost:3000/node_modules/ng2-sweetalert2(…)
我已经将设置放在systemjs.config中但它仍然不起作用
我的systemjs.config
var map = {
'app': 'dist', // 'dist',
'@angular': 'node_modules/@angular',
'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api',
'rxjs': 'node_modules/rxjs',
'angular2-cookie': 'node_modules/angular2-cookie',
'ng2-sweetalert2': 'node_modules/ng2-sweetalert2',
};
// packages tells the System loader how to load when no filename and/or no extension
var packages = {
'app': { main: 'main.js', defaultExtension: 'js' },
'rxjs': { defaultExtension: 'js' },
'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' },
'angular2-cookie': {main: 'core.js', defaultExtension: 'js'},
'ng2-sweetalert2': { defaultExtension: 'js' },
};
我的app.module
import { SweetAlertService } from 'ng2-sweetalert2';
enableProdMode();
const routes: Routes = [
];
@NgModule({
imports: [...], // module dependencies
declarations: [...], // components and directives
entryComponents: [...],
bootstrap: [ AppComponent ], // root component
providers: [... , SweetAlertService],
})
export class AppModule { }