Custom ExceptionHandler change detection lag

update ExceptionHandler was renamed to ErrorHandler https://stackoverflow.com/a/35239028/217408 orgiginal Change detection isn’t run at the end of the click event when the handler throws. You can invoke change detection manually but this gets a bit complicated because you need an ApplicationRef reference and ApplicationRef depends on ExceptionHandler which makes a neat cycle and DI can’t resolve … Read more

Angular 5 and Service Worker: How to exclude a particular path from ngsw-config.json

Thanks to the Pedro Arantes advice, I reached the next working config (see dataGroups and “maxAge”: “0u”): { “index”: “/index.html”, “dataGroups”: [ { “name”: “api”, “urls”: [“/api”], “cacheConfig”: { “maxSize”: 0, “maxAge”: “0u”, “strategy”: “freshness” } } ], “assetGroups”: [ { “name”: “app”, “installMode”: “prefetch”, “resources”: { “files”: [ “/favicon.ico”, “/index.html” ], “versionedFiles”: [ “/*.bundle.css”, … Read more

Angular2: how bind to select multiple

Why all those complicate answers about simple question. If you in advance have options which have to be selected, you can do it simply this way : This code is good : HTML <select multiple [(ngModel)]=”myModelProperty”> <option *ngFor=”#item of myOptions” [value]=”item.value”>{{item.name}}</option> </select> ANGULAR myModelProperty: any; myModelProperty = [‘YOUR_VALUE’, ‘YOUR_VALUE’]; or if you have string, you … Read more

Uncaught (in promise): Error: StaticInjectorError(AppModule)[options]

Here is what worked for me (Angular 7): First import HttpClientModule in your app.module.ts if you didn’t: import { HttpClientModule } from ‘@angular/common/http’; … imports: [ HttpClientModule ], Then change your service @Injectable() export class FooService { to @Injectable({ providedIn: ‘root’ }) export class FooService { Hope it helps. Edit: providedIn Determines which injectors will … Read more

Angular2 – Interpolate string with html

You can simply use [innerHTML] directive to accomplish it. http://plnkr.co/edit/6x04QSKhqbDwPvdsLSL9?p=preview import {Component, Pipe} from ‘@angular/core’ @Component({ selector: ‘my-app’, template: ` Hello my name is <span [innerHTML]=”myName”></span> `, }) export class AppComponent { myName=”<strong>Pardeep</strong>”; } Update: I checked it doesn’t work this way after RC.1 release. Let’s say to make it work with RC.4 you can … Read more

How do I get the absolute path of the current page in Angular 2?

constructor(location:Location) { console.log(location.prepareExternalUrl(location.path())); } https://angular.io/api/common/Location#prepareexternalurl As the documentation says: Normalizes an external URL path. If the given URL doesn’t begin with a leading slash (“https://stackoverflow.com/”), adds one before normalizing. Adds a hash if HashLocationStrategy is in use, or the APP_BASE_HREF if the PathLocationStrategy is in use. It means that you have to explicitly specify APP_BASE_HREF … Read more

Angular 4 checkbox change value

This it what you are looking for: <input type=”checkbox” [(ngModel)]=”isChecked” (change)=”checkValue(isChecked?’A’:’B’)” /> Inside your class: checkValue(event: any){ console.log(event); } Also include FormsModule in app.module.ts to make ngModel work ! Hope it Helps!