
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
ngx-loadable
Advanced tools
ngx-loadable: Simpler Lazy Loading Non Routable Angular Modules
The library logo represents faster application like speed of wind
Angular provides an easy way for adding route based lazy loading modules. But in most of the projects, each route tends to have a lot of different components. It could be because of lots of modals, tabs, and components that appear based on user interaction in a single route.
The ngx-loadable
wraps the complex implementation for lazy loading non routable modules in a simple API. It provides a component ngx-loadable
and a service LoadableService
to lazy load modules. A component can be used to control the loading of one module and to display different states, i.e. loading, error, timedOut and loaded.
Install and manage the ngx-loadable using NPM. You may use yarn
or npm
.
npm install ngx-loadable --save
or
yarn add ngx-loadable
Import the LoadableModule in the NgModule and declare them in the "imports", you can also use the forRoot()
for forChild()
function.
import { LoadableModule } from 'ngx-loadable';
@NgModule({
imports: [
LoadableModule
]
})
Step 2: Create a Module with a Component bootstrapped to the Module
Step 3: Include the module path in the lazyModules array in angular.json file, for it to be created as a lazy module by Angular CLI
Step 4:
Use the ngx-loadable
component
<button (click)="show = true" (mouseenter)="loginModalModule.preload()">
Preload on mouseenter and show on click
</button>
<ngx-loadable
#loginModalModule
[module]="'login-modal'"
[show]="show"
[timeout]="1000"
>
<div loading>Loading...</div>
<div error>Error</div>
<div timedOut>
TimedOut!
<button (click)="loginModalModule.reload()">
Reload
</button>
</div>
</ngx-loadable>
or use the LoadableService
import { LoadableService } from 'ngx-loadable';
...
class YourComponent {
contructor(private loadableService: LoadableService) { }
load() {
this.loadableService.preload('lazy')
.then(() => console.log('loaded'))
.catch((error) => console.error(error));
}
}
}
Please contribute by creating issues/PRs
© 2019 ngx-loadable. All Rights Reserved.
Thanks goes to these wonderful people (emoji key):
Zama Khan Mohammed 💻 🎨 💡 📖 🤔 🚇 | rumanhassan 🤔 💻 🔧 |
This project follows the all-contributors specification. Contributions of any kind welcome!
FAQs
ngx-loadable: Simpler Lazy Loading Non Routable Angular Modules
The npm package ngx-loadable receives a total of 30 weekly downloads. As such, ngx-loadable popularity was classified as not popular.
We found that ngx-loadable demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.