
Security News
Open Source CAI Framework Handles Pen Testing Tasks up to 3,600× Faster Than Humans
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
angular-service
Advanced tools
Wrap $http to handle service's 200 OK error response. Wrap pagination data to handle pageState indicated pagination data.
Ideally, when api rejects to service a client request, it should return an error message with http error codes such as 4xx, 5xx. But in reality there are APIs returns 200 OK http status code, but actually it fails to serve the client request. It defines another error code system instead of http status codes, so these 200 OK errors can't be caught by the $http's error callback, in consequence you will need to write error handling code in the success callback. And that's what this angular-service comes in handy, it enables you that only need to write error handling code in error callback.
npm install gulp-cli -g
npm install gulp -D
npm install
gulp
Run gulp
before making git commit
. So the dist
folder will be updated.
npm install angular-service
bower install angular-service
bower update angular-service
script(src="#{cdn.normal}bower_components/angular/angular.min.js?#{cdn.version}")
script(src="#{cdn.normal}bower_components/angular-service/dist/scripts/all.js?#{cdn.version}")
script.
angular.module('yourModule', ['servicesModule'])
.controller('yourCtrl', ['service', function(service){
service.get('xxx', {}).then(success, fail);
}])
;
There are 2 kinds of pagination: - pagination2: data was stored in cassandra or the same type of database, fetched by pageState, don't know the total records ahead of time - pagination-total: data was stored in solr or the same type of database, fetched by offset, and you can get the total records ahead of time
jade/pug template (Still haven't been using jade/pug? Use it, and convert your existing html to jade/pug by this tool: http://html2pug.jijiyy.me/)
div(ng-controller="yourCtrl")
table.ui.single.line.table
thead
tr
th 时间
th 项目
th 内容
tbody
tr(ng-repeat="record in yourDataRecords.records[yourDataRecords.pageIndex]")
td
span {{record.createDate | date : 'yyyy年M月d日'}}
br
span {{record.createDate | date: 'hh:mm'}}
td
div(ng-repeat="p in record.product") {{p.name}}
td.ui.middle.aligned
span.middle.aligned {{record.type === 'I' ? '+' : (record.type === 'E' ? '-' : '')}}{{record.amount}}
tfoot
tr
th(colspan="3")
include ../../public/bower_components/angular-service/views/pagination2.jade
+ pagination2('yourDataRecords')
javascript
angular.module('yourModule', ['servicesModule'])
.controller('yourCtrl', ['$scope', 'service', 'paginationData', function ($scope, service, paginationData) {
$scope.yourDataRecords = new paginationData('http://your/data/source/url');
$scope.yourDataRecords.getNextPage();
}])
.controller('anotherCtrl', ['$scope', 'service', 'paginationData', function ($scope, service, paginationData) {
$scope.yourDataRecords = new paginationData('http://your/data/source/url', {pageSize: 5});
$scope.yourDataRecords.getNextPage();
}])
.controller('yetAnotherCtrl', ['$scope', 'service', 'paginationData', function ($scope, service, paginationData) {
$scope.yourDataRecords = new paginationData('http://your/data/source/url');
$scope.yourDataRecords.getNextPage({pageSize: 15});
}])
;
div(ng-controller="yourCtrl")
table.ui.single.line.table
thead
tr
th 时间
th 项目
th 内容
tbody
tr(ng-repeat="record in yourDataRecords.records[yourDataRecords.pageIndex]")
td
span {{record.createDate | date : 'yyyy年M月d日'}}
br
span {{record.createDate | date: 'hh:mm'}}
td
div(ng-repeat="p in record.product") {{p.name}}
td.ui.middle.aligned
span.middle.aligned {{record.type === 'I' ? '+' : (record.type === 'E' ? '-' : '')}}{{record.amount}}
tfoot
tr
th(colspan="3")
include ../../public/bower_components/angular-service/views/pagination-total.jade
+ paginationTotal('yourDataRecords')
javascript
angular.module('yourModule', ['servicesModule'])
.controller('yourCtrl', ['$scope', 'service', 'paginationDataWithTotal', function ($scope, service, paginationDataWithTotal) {
$scope.yourDataRecords = new paginationDataWithTotal('http://your/data/source/url');
$scope.yourDataRecords.getNextPage();
}])
.controller('anotherCtrl', ['$scope', 'service', 'paginationDataWithTotal', function ($scope, service, paginationDataWithTotal) {
$scope.yourDataRecords = new paginationDataWithTotal('http://your/data/source/url', {pageSize: 5});
$scope.yourDataRecords.getNextPage();
}])
.controller('yetAnotherCtrl', ['$scope', 'service', 'paginationDataWithTotal', function ($scope, service, paginationDataWithTotal) {
$scope.yourDataRecords = new paginationDataWithTotal('http://your/data/source/url');
$scope.yourDataRecords.getNextPage({pageSize: 15});
}])
;
FAQs
Wrap $http to handle service's 200 OK error response.
The npm package angular-service receives a total of 44 weekly downloads. As such, angular-service popularity was classified as not popular.
We found that angular-service demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.