1.1.3 • Published 3 years ago
ngx-shareit v1.1.3
Ngx-ShareIt
Amazing package for data sharing from anywhere of the application to anywhere. It has really simple mechanism of doing it, just plug and play ..
Features
- Share/Broadcast data.
- Share data from any level of the component in application.
- Access data from any level of component in application
- Really lightweight
Usage
Import in module.
imports: [
BrowserModule,
NgShareModule
],
Add in component.
export class AppComponent {
constructor(private dataSer: DataSharingService) { }
}
Share Data from any component like.
shareUsers() {
// keep one thing in mind always share data in object format
this.dataSer.shareData({ users: '// Array of users data' });
//or multiple values from different components
this.dataSer.shareData({ name: 'specific name' });
}
Access Full Data from any component like.
getUsers() {
this.dataSer.getData().subscribe(data => {
console.log(data);
//ouput :
//{
// users : *array data*,
// name : *name data*
//}
});
}
Access Specific Data from any component like.
getSpecificData() {
this.dataSer.getSpecificData('users').subscribe(data => {
console.log(data);
//ouput:
// *name data*
})
}