https://github.com/stefh/angular-odata-es5
OData Service for Angular.io (es5 version)
https://github.com/stefh/angular-odata-es5
angular angular2 fluent odata service
Last synced: 6 months ago
JSON representation
OData Service for Angular.io (es5 version)
- Host: GitHub
- URL: https://github.com/stefh/angular-odata-es5
- Owner: StefH
- License: mit
- Created: 2017-03-16T12:40:59.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2023-03-01T13:45:20.000Z (about 3 years ago)
- Last Synced: 2025-09-15T06:35:14.837Z (7 months ago)
- Topics: angular, angular2, fluent, odata, service
- Language: TypeScript
- Homepage:
- Size: 39.3 MB
- Stars: 43
- Watchers: 9
- Forks: 26
- Open Issues: 28
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Angular OData Library (es5)
[](https://greenkeeper.io/)
[](https://travis-ci.org/StefH/angular-odata-es5)
[](https://codecov.io/gh/StefH/angular-odata-es5)
[](http://badge.fury.io/js/angular-odata-es5)
## Demo
https://StefH.github.io/angular-odata-es5/demo/
## Table of contents
- [About](#about)
- [Installation](#installation)
- [Usage example](#usage)
- [Documentation](#documentation)
- [Development](#development)
## About
The goal is to create a fluent API for querying, creating, updating and deleting OData resources in Angular > 2.
Note that this library targets 'es5' so that Uglify will work correctly.
## Installation
Install through npm:
```
npm install --save angular-odata-es5
```
## Usage
``` typescript
import { ODataConfiguration, ODataServiceFactory, ODataService } from "angular-odata-es5";
import { bootstrap } from "@angular/platform/browser";
@Injectable()
class MyODataConfig extends ODataConfiguration{
baseUrl="http://localhost:54872/odata/";
}
bootstrap(app, [
provide(ODataConfiguration, { useClass:MyODataConfig }),
ODataServiceFactory,
]
//An example model interface
interface INotification {
Id: number;
CommentId: number;
Comment: IComment;
FromId: number;
From: IResource;
Priority: number;
SendDate: Date;
IsArchived: boolean;
Text: string;
}
//An example component
@Component({
...
})
export class NotyListComponent {
private odata: ODataService;
constructor(private odataFactory: ODataServiceFactory, ...) {
this.odata = this.odataFactory.CreateService("notification");
}
getOneNoty(id: number) {
this.odata.Get(id).Select("Id,Text").Expand("From,To").Exec()
.subscribe(
singleNoty => {...},
error => {...}
);
}
getNotys(){
this.odata
.Query() //Creates a query object
.Top(this.top)
.Skip(this.skip)
.Expand('Comment, From')
.OrderBy('SendDate desc')
.Filter(this.filterString)
.Exec() //Fires the request
.subscribe( //Subscribes to Observable>
notys => {
this.notys = notys; //Do something with the result
},
error => {
... //Local error handler
});
}
}
```
You may also find it useful to view the [demo source](https://github.com/StefH/angular-odata-es5/blob/master/demo/demo.component.ts).
### Usage without a module bundler
``` javascript
// everything is exported AngularODataES5 namespace
```
## Documentation
All documentation is auto-generated from the source via [compodoc](https://compodoc.github.io/compodoc/) and can be viewed here:
https://StefH.github.io/angular-odata-es5/docs/
## Development
### Prepare your environment
* Install [Node.js](http://nodejs.org/) and NPM (should come with)
* Install local dev dependencies: `npm install` while current directory is this repo
### Development server
Run `npm start` to start a development server on port 8000 with auto reload + tests.
### Testing
Run `npm test` to run tests once or `npm run test:watch` to continually run tests.