【发布时间】:2018-01-08 08:03:45
【问题描述】:
.NET Core 的 ABP 模板是否具有Javascript-API 中列出的功能?
更重要的是,.NET Core 版本能否生成我的服务器端实体对应的动态代理(services.ts)?
【问题讨论】:
标签: angular typescript .net-core aspnetboilerplate dynamic-proxy
.NET Core 的 ABP 模板是否具有Javascript-API 中列出的功能?
更重要的是,.NET Core 版本能否生成我的服务器端实体对应的动态代理(services.ts)?
【问题讨论】:
标签: angular typescript .net-core aspnetboilerplate dynamic-proxy
是的,.NET Core 的 ABP 模板具有Javascript-API 中列出的所有功能。
ABP 不生成动态代理。推荐工具used by the ABP team是NSwag:
我们正在使用 nswag 来生成 typescript 服务代理。 Nswag 使用 swagger 端点来获取服务定义并自动创建 typescript 类。既然有这么棒的工具,我们就不想研究了。
【讨论】:
是的,它支持核心版本的所有功能。但没有动态代理创建。您在 Angular 版本中使用 abp.ajax 处理应用服务请求。
abp.ajax({
url: AppConsts.remoteServiceBaseUrl + '/AbpUserConfiguration/GetAll',
method: 'GET',
}
}).done(result => {
//....
});
nswag 生成服务的使用示例;
constructor(
injector: Injector,
private _accountService: AccountServiceProxy,
private _router: Router,
private readonly _loginService: LoginService
) {
super(injector);
}
save(): void {
this.saving = true;
this._accountService.register(this.model)
.finally(() => { this.saving = false; })
.subscribe((result:RegisterOutput) => {
if (!result.canLogin) {
this.notify.success(this.l('SuccessfullyRegistered'));
this._router.navigate(['/login']);
return;
}
//Autheticate
this.saving = true;
this._loginService.authenticateModel.userNameOrEmailAddress = this.model.userName;
this._loginService.authenticateModel.password = this.model.password;
this._loginService.authenticate(() => { this.saving = false; });
});
}
【讨论】: