ngx-can-activate-app
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

NgxCanActivateApp

Can Activate Angular

1. Install ngx-can-activate-app

npm i -s ngx-can-activate-app

2. Create component

It will be displayed until your application has finished activating.

import { NgxCanActivateApp } from 'ngx-can-activate-app';
 
@Component({
  selector: 'app-confirmation',
  template: '<button (click)="onActivate()">Activate</button>'
})
export class ConfirmationComponent {
  constructor(private canActivateApp: NgxCanActivateApp) {}
 
  onActivate() { this.canActivateApp.activate(); }
}

3. Declare the component

Add it to declarations.

@NgModule({
  declarations: [ AppComponent, ConfirmationComponent ],
  bootstrap: [ AppComponent ]
})
export class AppModule {}

4. Import NgxCanActivateAppModule

Then add your component to the module's initialization.

import { NgxCanActivateAppModule } from 'ngx-can-activate-app';
 
@NgModule({
  imports: [
    NgxCanActivateAppModule.forRoot({
      component: ConfirmationComponent
    })
  ],
  declarations: [ AppComponent, ConfirmationComponent ],
  bootstrap: [ AppComponent ]
})
export class AppModule {}

5. Specify a selector in index.html

Add the selector of your component to index.html.

<!doctype html>
<html lang="en">
<head></head>
<body>
  <app-root>
      <app-confirmation></app-confirmation>
  </app-root>
</body>
</html>

Package Sidebar

Install

npm i ngx-can-activate-app

Weekly Downloads

1

Version

0.0.3

License

MIT

Unpacked Size

104 kB

Total Files

27

Last publish

Collaborators

  • thekiba