Installation Part 1

Angular CLI >= 1.6.0 (Otherwise, you can do manually, but bellow version are not stable)

Angular >= 5.0.0 or later


            ng new PROJECT-NAME --service-worker (or using the alias — -sw )
        

Installation Part 2


            # src/app/app.module.ts
                ...
            import { ServiceWorkerModule } from '@angular/service-worker';
            import { environment } from '../environments/environment';
    
            @NgModule({
                ...
            imports: [
                ...
                ServiceWorkerModule.register('/ngsw-worker.js', { enabled: environment.production })
            ],
                ...
            })
            export class AppModule { }
        

            # .angular-cli.json added property
            apps.serviceWorker=true