0
我想发送API调用controller.js到service.js在我的demo.i显示用户列表中的演示,我用于angularjs数据表与web api.and我的结构是app.js,controller.js,服务.js使用这3个单独的文件。 然后我想发送电话service.js。如何使用angular.js web api将api call controller.js发送到service.js?
这是我简单的controller.js代码,运行良好。
app.controller('userscontroller', ['$scope', '$http', 'DTOptionsBuilder', 'DTColumnBuilder', 'userservice',
function ($scope, $http, DTOptionsBuilder, DTColumnBuilder, userservice) {
$scope.dtColumns = [
DTColumnBuilder.newColumn("fullName", "Full Name").withOption('name', 'firstname'),
DTColumnBuilder.newColumn("email", "Email").withOption('name', 'email'),
]
$scope.dtoptions = dtoptionsbuilder.newoptions().withoption('ajax', {
datasrc: "data",
url: "/home/getuserlist",
type: "post",
data: { 'type': "time"},
})
.withoption('processing', true)
.withoption('serverside', true)
.withpaginationtype('full_numbers')
.withdisplaylength(10)
.withoption('aasorting', [0, 'asc'])
}])
这个我service.js文件:
app.service('userservice', function ($http) {});
任何一个有想法如何调用使用service.js那么请让我知道这个API调用。
如何管理“$ scope.dtoptions = dtoptionsbuilder.newoptions()。withoption(”在你的代码中的这个代码请让我知道,实际上这个用于获取用户的列表 – coderwill
因此,你想使用'dtoptionsbuilder'而不是简单的'$ http'? – eminlala
可能是的我不知道如何使用这个API调用是你详细解释所以它的面糊我 – coderwill