【发布时间】:2017-11-29 15:05:56
【问题描述】:
我知道之前有人问过this question,但我的问题是关于在 JavaScript 中直接使用 abp.services 方法。
假设我有:
public interface ISecurityAppService : IApplicationService
{
List<PacsUser_C_Extented> GetAll();
}
public class SecurityAppService : ApplicationService, ISecurityAppService
{
public List<PacsUser_C_Extented> GetAll()
{
// ...
return allUsers;
}
}
所有样板服务都将很好地注册为:
public class Global : AbpWebApplication<ImmenseWebModule>
{
protected override void Application_Start(object sender, EventArgs e)
{
base.Application_Start(sender, e);
}
}
正如ASP.NET Boilerplate 文档所说,为了能够使用自动生成的服务,您应该在页面中包含所需的脚本,例如:
<script src="~/Abp/Framework/scripts/libs/angularjs/abp.ng.js"></script>
<script src="~/api/AbpServiceProxies/GetAll?type=angular"></script>
我知道第二行说要使用angular 控制器,但我将其更改为:
<script src="~/api/AbpServiceProxies/GetAll?v=@(Clock.Now.Ticks)">script>
...仍然没有任何效果。
当我想在 ASP.NET Web 窗体的 JavaScript 代码中使用 getAll 时,它给了我:
abp.service 未定义
那么我如何在脚本元素<script>...</script> 中使用getAll 或SecurityAppService 中的其他方法——而不是Angular?
提前致谢。
更新
当我使用 Angular 控制器和 MVC 局部视图时:
(function () {
var app = angular.module('app');
var controllerId = 'sts.views.security.list';
app.controller(controllerId, [
'$scope', 'abp.services.remotesystem.security',
function ($scope, securityService) {
var vm = this;
vm.localize = abp.localization.getSource('ImmenseSystem');
vm.users = [];
vm.refreshUserList = function () {
abp.ui.setBusy( // Set whole page busy until getTasks completes
null,
securityService.getAll().success(function (data) {
vm.users = data;
abp.notify.info(vm.localize('UserListLoaded'));
})
);
};
vm.refreshUserList();
}
]);
})();
我可以使用该功能。 但我想在 ASP.NET Web 表单页面的 JavaScript 中使用它。
【问题讨论】:
-
abp.service is not defined→ 你忘了abp.services中的s吗? -
@arron No
s被错过了,我试过abp.services
标签: javascript asp.net webforms aspnetboilerplate