angular

Add custom color variables in angular material (2+)

懵懂的女人 提交于 2021-02-18 22:12:06
问题 How to create "custom" own colors for angular material? For example the bootstrap like colors like success (green), warn (yellow), danger (red), beside primary (blue), accent (pink). In other words: Extend the color variablen of Angular Material (2+) for using it in html attributes: <button mat-raised-button color="success">Success</button> or create a white checkbox like: <mat-checkbox color="white">Check me!</mat-checkbox> 回答1: To add a new color named success , make the following changes

Angular2: How to subscribe to Http.post observable inside a service and a component properly?

纵然是瞬间 提交于 2021-02-18 22:10:25
问题 For a JWT authentification, I make a post request to get the token using the new Http module working with Observables now. I have a simple Login component showing the form: @Component({ selector: 'my-login', template: `<form (submit)="submitForm($event)"> <input [(ngModel)]="cred.username" type="text" required autofocus> <input [(ngModel)]="cred.password" type="password" required> <button type="submit">Connexion</button> </form>` }) export class LoginComponent { private cred: CredentialsModel

Angular2: How to subscribe to Http.post observable inside a service and a component properly?

本秂侑毒 提交于 2021-02-18 22:10:02
问题 For a JWT authentification, I make a post request to get the token using the new Http module working with Observables now. I have a simple Login component showing the form: @Component({ selector: 'my-login', template: `<form (submit)="submitForm($event)"> <input [(ngModel)]="cred.username" type="text" required autofocus> <input [(ngModel)]="cred.password" type="password" required> <button type="submit">Connexion</button> </form>` }) export class LoginComponent { private cred: CredentialsModel

Angular - Unhandled Navigation Error after building

前提是你 提交于 2021-02-18 22:08:47
问题 I have built a simple angular app with 2 routes through the following command: ng build --aot --prod --base-href ./ Then i open the index.html file located in the dist folder and the app runs but the the routes don't work and i get the following warning on console: Hope to have explained my question well. Thanks in advance. 回答1: Using Angular routing engine will force you to host your app in some server (e.g. IIS, NodeJS etc.) A simple angular app without routes can run without hosting it on

rxjs: perform some action regulary with specific delay in between

北战南征 提交于 2021-02-18 21:10:49
问题 Client applications sends request to server, that could potentially take long to complete. Once request is finished or failed, client should wait some period of time (i.e. 10 seconds) and then again send the request. Current working solution is this: appRequest = new Subject(); ngOnInit(): void { this.appRequest.delay(10000).subscribe(() => this.refresh()); this.refresh(); } refresh() { this.api.getApplications().subscribe(a => { this.updateApplications(a); this.appRequest.next(); },() =>

What is the ideal way to sort a FormArray object in Angular 2+?

点点圈 提交于 2021-02-18 21:00:47
问题 I have a formArray which consist of multiple form groups. I need to sort the array dynamically based on a boolean field present in each of the form group in the array. The boolean field is a checkbox and at any given point of time only one checkbox can be checked (mimics radio button). So when a checkbox is clicked I need to sort the formArray based on the one that is selected. I know the documentation suggests not to mess with the AbstractControls[] present in the formArray, so what would be

Injecting ngControl in custom validator directive, causes cyclic dependency

给你一囗甜甜゛ 提交于 2021-02-18 20:41:26
问题 i'm trying to create custom angular 2 validator directive, which inject NgControl like this : @Directive({ selector: '[ngModel][customValidator]', providers: [{provide: NG_VALIDATORS, useExisting: CustomValidatorDirective, multi: true}] }) export class CustomValidatorDirective implements Validator { private validateFunction: ValidatorFn; constructor(private control: NgControl) { }; } But i get the following error: Cannot instantiate cyclic dependency! NgControl Does anyone know how i can

No value accessor for form control with name… for mat-select controls

坚强是说给别人听的谎言 提交于 2021-02-18 20:09:24
问题 I am making some unit test with jasmine and karma for an angular 6 app that validate if a formGroup field is valid. I am experiencing problems with mat-select control. when I run the test case, Karma fires me an error saying Error: No value accessor for form control with name: 'importId' . By the way, the component works fine as I expected. This is my component: import {Component, Inject, OnInit} from '@angular/core'; import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material"; import

Angular 2 continuous deployment with jenkins and seperate production server

只愿长相守 提交于 2021-02-18 19:36:59
问题 I would like to know what is best practice for running Angular 2 in production. I am asked to build a software factory (continuous integration, automated build, automated deployment). What confuses me is this: We don't use a development server. We're expected to deploy the application and its dependencies to a real production server. https://angular.io/docs/ts/latest/guide/webpack.html#!#production-configuration Why do I have to run the application on the same server? Currently I have set-up

Angular 2 continuous deployment with jenkins and seperate production server

走远了吗. 提交于 2021-02-18 19:35:36
问题 I would like to know what is best practice for running Angular 2 in production. I am asked to build a software factory (continuous integration, automated build, automated deployment). What confuses me is this: We don't use a development server. We're expected to deploy the application and its dependencies to a real production server. https://angular.io/docs/ts/latest/guide/webpack.html#!#production-configuration Why do I have to run the application on the same server? Currently I have set-up