ng-aqueduct
v0.0.10
Published
![](docs/aqueduct.png)
Downloads
4
Readme
NgAqueduct library
Provides connection between Angular (7+) and Laravel (Laravel Helpers)
Installation
npm i ng-aqueduct --save
Set config and add NgAqueductModule into AppModule.
const environmentConfig = {
url: 'https://api.site.com',
domains: ['api.site.com']
};
@NgModule({
...
imports: [
...
NgAqueductModule.forRoot(environmentConfig),
...
],
})
How to use
If you are planning to use Aqueduct into service just extends service from the ApiService
import { ApiService, RequestTypes } from 'ng-aqueduct';
@Injectable({
providedIn: 'root'
})
export class MyService extends ApiService<MyInterface> {
}
Note! An interface MyInterface must contains id field or extends from the ApiEntity interface. It neccessary for working with update/get methods.
Now you can use all CRUD methods. Read detailed information in documentation about requests and responses.
export class MyComponent {
constructor(
private myService: MyService,
) { }
addAction(data: MyInterface) {
this.myService
.add(data)
.then(response => {
...
});
}
getAction(id: string | number) {
this.myService
.get(id)
.then(response => {
...
});
}
updateAction(id: number, status: bool) {
const data = {
id: id,
status: status
};
this.myService
.update(data)
.then(response => {
...
});
}
anotherUpdateAction(data: MyInterface) {
this.myService
.update(data)
.then(response => {
...
});
}
deleteAction(id: string | number) {
this.myService
.delete(id)
.then(response => {
...
});
}
}