@outsiderninjadevs/core
v17.0.1-rc1
Published
@outsiderninjadevs/core is the Angular core library for the core utils. it has services that helps to build better angular apps with the most helpful functionnalities.
Downloads
12
Maintainers
Readme
@outsiderninjadevs/core
@outsiderninjadevs/core is the Angular core library for the core utils. it has services that helps to build better angular apps with the most helpful functionalities.
Features
- Generate and download CSV files.
Installation
You can install @outsiderninjadevs/core via npm:
npm install @outsiderninjadevs/core
You also can explicitly give the version
npm install @outsiderninjadevs/[email protected]
Usage
We strongly recommend using the new angular 17 standalone apps, that's why we have no more the
OndCoreModule
Create the list of elements
// imports interface IUser { name: string; age: number; is_an_admin?: boolean; } @Component({ // properties }) export class MyComponent { usersList: IUser[] = [ { name: 'Achraf', age: 24 }, { name: 'Alae', age: 18 }, // ... ]; }
We need to inject the
OndCsvBuilderService
in out componentimport {OndCsvBuilderService} from '@outsiderninjadevs/core'; // imports @Component({ // properties }) export class MyComponent { constructor( private readonly csv: OndCsvBuilderService ) {} }
We build the csv then we download.
import {OndCsvBuilderService} from '@outsiderninjadevs/core'; // imports interface IUser { name: string; age: number; is_an_admin?: boolean; } @Component({ // properties }) export class MyComponent { usersList: IUser[] = [ { name: 'Achraf', age: 24 }, { name: 'Alae', age: 18 }, // ... ]; constructor( private readonly csv: OndCsvBuilderService ) {} on_click(){ // toCSVAsync and downloadCSVAsync are asynchronous functions csv.toCSVAsync<IUser>(usersList, ";") // the delimiter (;) is optional .then(async csvString => { try{ await csv.downloadCSVAsync(csvString, "users.csv"); } catch (errorDown => { alert("Error on download " + errorDown); }) }).catch(error => { alert("Error " + error); }); } }
License
This project is licensed under the MIT License - see the LICENSE
file for details.