angular6

Angular6 Service Worker and background sync

☆樱花仙子☆ 提交于 2019-11-30 21:06:52
it seems that angular6 does not support background syncing with service worker. What are the steps required to do this without any library in an angular service? https://developers.google.com/web/updates/2015/12/background-sync How and where can I access WorkerGlobalScope in an angular6 application directly so that background sync can be done.: self.addEventListener('sync', function(event) { if (event.tag == 'myFirstSync') { event.waitUntil(doSomeStuff()); } }); The problem is that the angular CLI generates the servicworker file ( ngsw-worker.js ). Is there a way to inject / modify / extend

Use jQuery script with Angular 6 CLI project

时间秒杀一切 提交于 2019-11-30 19:05:27
问题 I'm developing an application using angular 6. My application use Minton Theme . I included all theme scripts in the index.html file of my angular project. But when I logged in or navigate between routes some jquery methods not working properly. I had to refresh page manually to make them work. Is there an fix for this? I couldn't find any working solution yet. Project components structure app -components --footer --left-side-bar --header --pages ---dashboard ----home ----accounts ---login

Pass image from FileReader to form input in Angular 6

本小妞迷上赌 提交于 2019-11-30 17:15:57
问题 I try to create an UI where there is a form with a couple of text fields, a input type="file" and a div that you can drop images to upload with the rest of the form. My goal / logic use the same div to either drop an image or click on it and open the folder explorer like the input type="file" behaves. Enabling clicking makes sense in small screens where it is practically impossible to "drag and drop". And since there is already a input type="file" in the form there is no reason to take the

Fill custom SVG image using percentage value

纵饮孤独 提交于 2019-11-30 16:42:52
I want to fill the custom SVG image with percentage value in Angular 6 using typescript or using CSS. Is there any tool available for that? Custom image can be anything like $, gear icon, thumb etc. Any help would be appreciated. The simplest method is probably with a linear gradient. function setProgress(amt) { amt = (amt < 0) ? 0 : (amt > 1) ? 1 : amt; document.getElementById("stop1").setAttribute("offset", amt); document.getElementById("stop2").setAttribute("offset", amt); } setProgress(0.25); <svg width="400" height="400"> <defs> <linearGradient id="progress" x1="0" y1="1" x2="0" y2="0">

Async authguard in angular 6

扶醉桌前 提交于 2019-11-30 15:49:02
I would like to provide a server-side authentication before I give access to a specific route in angular. I have a AuthGuard which implements CanActivate and a service AuthService. The authService already has a private loggedIn: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(null); which views subscribe to in order to know if the user is logged in or not. I don't really know if my approach is wrong, but it does not seem to work. This is what I have in auth.guard.ts: canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot) : Observable<boolean> { return this.authService

Angular component in a Browser's child window

試著忘記壹切 提交于 2019-11-30 14:43:41
问题 From an Angular application is there any way that I can create a Browser's child window and show some predefined angular component in it. Clarification : I am not looking for a Modal dialog solution. 回答1: In case you are using window.open for the child window in order to show an angular component that window should load a website which uses angular this means you eighter create in your own app a child route special for that page and you open your own app to that specific route. If you chose

Angular 6 CLI -> how to make ng build build project + libraries

◇◆丶佛笑我妖孽 提交于 2019-11-30 14:42:13
问题 So the question is pretty basic but I can't find it. I created a new app through ng new my-project , followed by a ng g library my-library . Then I executed the command ng build , but is is only building my app, and not my library or my e2e projects. This is because in the angular.json defaultProject is set to my-project. I could change it to my-library, and then ng build will build the lib. Is there a way to let angular build all the project and the libraries in one ng-build? 回答1: I just

Angular 6 CLI -> how to make ng build build project + libraries

会有一股神秘感。 提交于 2019-11-30 11:49:12
So the question is pretty basic but I can't find it. I created a new app through ng new my-project , followed by a ng g library my-library . Then I executed the command ng build , but is is only building my app, and not my library or my e2e projects. This is because in the angular.json defaultProject is set to my-project. I could change it to my-library, and then ng build will build the lib. Is there a way to let angular build all the project and the libraries in one ng-build? I just added a script to package.json to do that, could not find a better way. "scripts": { "build-all": "ng build

Angular : how to call finally() with RXJS 6

痴心易碎 提交于 2019-11-30 11:04:26
I was using RXJS 5, now as I upgraded it to 6, I am facing some problems. Previously I was able to use catch and finally but as per update catch is replaced with catchError (with in the pipe) now how to use finally? Also I have some questions : Do I need to change throw->throwError (in below code Observable.throw(err);) import { Observable, Subject, EMPTY, throwError } from "rxjs"; import { catchError } from 'rxjs/operators'; return next.handle(clonedreq).pipe( catchError((err: HttpErrorResponse) => { if ((err.status == 400) || (err.status == 401)) { this.interceptorRedirectService

WebStorm - Argument type {providedIn: “root”} is not assignable to parameter type {providedIn: Type<any> | “root” | null} & InjectableProvider

北慕城南 提交于 2019-11-30 11:01:58
I'm trying to migrate my app from Angular v5 to v6 and I face the following typescript error while trying to specify providedIn in my providers Argument type {providedIn: "root"} is not assignable to parameter type {providedIn: Type | "root" | null} & InjectableProvider @Injectable({ providedIn: 'root', }) export class MyService { } I copied and pasted the code from the Angular doc https://angular.io/guide/dependency-injection Any idea? UPDATE I have created a blank project ng new ... and added a provider ng g service my-new-service , opened the project in WebStorm and everything was ok, I