Change style of pseudo elements in angular2

You can achieve what you need with CSS variables. In your style sheet you can set the background image like this: .featured-image:after { content: ”; background-image: var(–featured-image); } After that you can programmatically set this variable on the same element or higher up in the DOM tree: <div class=”featured-image” [ngStyle]=”{‘–featured-image’: featuredImage}”> More about CSS variables … Read more

Chrome – Debug Angular/Typescript – how to navigate to ts file

Angular uses webpack and all type script files are listed under it. To select your target typescript file, Chrome’s Developer tool (F12). Go to Source tab, Select Chrome “webpack://”->”src/app” -> your typescript file. Or in older version of chrome follow this path “webpack://”->”.”->”src/app” -> your typescript file ( See the image file). Or Ctrl+P to … Read more

Playing HTML 5 video from Angular 2 Typescript

Problem is you’re trying to get a reference to video element using its id. You need to use template reference variable (#) instead: <div class=”video”> <video controls (click)=”toggleVideo()” #videoPlayer> <source src=”https://stackoverflow.com/questions/40360174/{{videoSource}}” type=”video/mp4″ /> Browser not supported </video> </div> Read more about template reference variable here. Edit: Also, in your toggleVideo(event: any) function, you need to … Read more

Invalid provider for the NgModule ‘DynamicTestModule’ when testing a service in Angular 2

This is such an annoying error, thought I’d include another subtle cause to look for in your spec. In my case I specified providers instead of the correct value of provide as below TestBed.configureTestingModule({ providers: [{provider: ApplicationActions, useClass: ActionMock}] rather than offer useful information like “no ‘provide’ key specified” it simply reports Failed: Invalid provider … Read more

password and confirm password field validation angular2 reactive forms

This is what eventually worked for me – this.addEditUserForm = this.builder.group({ firstName: [”, Validators.required], lastName: [”, Validators.required], title: [”, Validators.required], email: [”, Validators.required], password: [”, Validators.required], confirmPass: [”, Validators.required] },{validator: this.checkIfMatchingPasswords(‘password’, ‘confirmPass’)}); checkIfMatchingPasswords(passwordKey: string, passwordConfirmationKey: string) { return (group: FormGroup) => { let passwordInput = group.controls[passwordKey], passwordConfirmationInput = group.controls[passwordConfirmationKey]; if (passwordInput.value !== passwordConfirmationInput.value) { return … Read more

Angular – Material: Progressbar custom color?

You can use ::ng-deep selector to achieve what you want, this answer has some info on it. How I did it: CSS ::ng-deep .mat-progress-bar-fill::after { background-color: #1E457C; } ::ng-deep .mat-progress-bar-buffer { background: #E4E8EB; } ::ng-deep .mat-progress-bar { border-radius: 2px; } HTML <mat-progress-bar mode=”determinate” value=”{{progress}}”></mat-progress-bar> And the result is this: EDIT: I found a way to … Read more