README
lnl-angular-tools
It is a Container of several services that easing life code in angular.
Install
install package
npm install --save lnl-angular-tools
In app module or auther module import:
import { BrowserModule } from '@angular/platform-browser';
...
import { LnlToolsModule } from 'lnl-angular-tools';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
...
LnlToolsModule
],
providers: [...],
bootstrap: [AppComponent]
})
export class AppModule { }
- In services or components import services and enjoy
Services
FileConverterService
Services list
This service convert a file to base64 using an Observable
import { Component, OnInit } from '@angular/core';
...
import { FileConverterService } from 'lnl-angular-tools';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
static me;
constructor(public fileConverter: FileConverterService) {
AppComponent.me = this;
}
ngOnInit() {
this.convertImgToBase64(); // boostrap listener function for convertion file
}
/**
* listener function that perform request for convertion
*/
convertImgToBase64()
{
this.fileConverter.init('#imginp', 'http://www.mysite.com/image.png');
this.fileConverter.champ.addEventListener('change', () => {
let obs = this.fileConverter.convertToBase64()
.subscribe({
next(base64: any) {
// we can get here Base64 string
},
error (err: any) {
//error of convertion base64
}
});
});
}
}
FileConveterService documentation
init (selector: string, default_link: string) : void
selector
parameter is id of input
default_link
parameter is url of default file; good for images
convertToBase64 ()
convert file to base64 and return an Observable
LnlMiscService
Services list
this is mescelaneous service
LnlMiscService documentation
jsonToUrlEncoded(jsonElt: any[]) : string
convert a one level json array to urlencoded string
orderedJsonId(obj : any[] | Object) : Object | any[]
order keys of an object and set old key as old_key propertie
Licence
MIT License
Copyright (c) 2018 nehemie konan
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.