angular5

How to persist service data after reload in angular 5

爷,独闯天下 提交于 2020-07-18 14:28:49
问题 I have a service to pass data between components and when called it works but when i reload the service data gets reset.So when i searched on reload the memory is reset so is there a way to persist data even after reload without using any client side storage ? One thing i am curious is that can i achieve this using rxjs but i am not sure how this would help ?I fear to use localstorage because the data will be mostly objects or array and not user id or session id.Any inputs on this would be

How to persist service data after reload in angular 5

血红的双手。 提交于 2020-07-18 14:28:13
问题 I have a service to pass data between components and when called it works but when i reload the service data gets reset.So when i searched on reload the memory is reset so is there a way to persist data even after reload without using any client side storage ? One thing i am curious is that can i achieve this using rxjs but i am not sure how this would help ?I fear to use localstorage because the data will be mostly objects or array and not user id or session id.Any inputs on this would be

angular 5 conditionally validate field based on another field's value

巧了我就是萌 提交于 2020-07-09 13:27:45
问题 How to conditionally validate a field based on another field's value? Here's what i've tried but it seems not to work this.PDform = _formbuilder.group({ [...] 'intlNumber': ['',this.nationality == 'Abroad' ? Validators.compose([Validators.pattern(this.phoneNumberExp), Validators.maxLength(14), Validators.minLength(11), Validators.required]) : Validators ] [...] }) 回答1: You can change the validators for a form control when the value of another form control changes by subscribing to the

angular 5 conditionally validate field based on another field's value

谁说我不能喝 提交于 2020-07-09 13:24:49
问题 How to conditionally validate a field based on another field's value? Here's what i've tried but it seems not to work this.PDform = _formbuilder.group({ [...] 'intlNumber': ['',this.nationality == 'Abroad' ? Validators.compose([Validators.pattern(this.phoneNumberExp), Validators.maxLength(14), Validators.minLength(11), Validators.required]) : Validators ] [...] }) 回答1: You can change the validators for a form control when the value of another form control changes by subscribing to the

angular 5 conditionally validate field based on another field's value

核能气质少年 提交于 2020-07-09 13:24:03
问题 How to conditionally validate a field based on another field's value? Here's what i've tried but it seems not to work this.PDform = _formbuilder.group({ [...] 'intlNumber': ['',this.nationality == 'Abroad' ? Validators.compose([Validators.pattern(this.phoneNumberExp), Validators.maxLength(14), Validators.minLength(11), Validators.required]) : Validators ] [...] }) 回答1: You can change the validators for a form control when the value of another form control changes by subscribing to the

How to change time from 24 to 12 hour format in angular 5

大憨熊 提交于 2020-07-08 13:34:28
问题 I have used input type time in my application to receive time: <mat-input-container> <input matInput formControlName="start_time" type="time" placeholder="Time Start"> <p class="invalid-text" *ngIf="dvrForm.controls.start_time.invalid && (dvrForm.controls.start_time.dirty || dvrForm.controls.start_time.touched)"> <span *ngIf="dvrForm.controls.start_time.errors.required"> Start Time is required.</span></p> And after i store data through input it gets stored in 24 hour format : So now when I

How to dynamically change fxFlex value in Angular5 on a static screen-size?

北城余情 提交于 2020-07-08 07:48:40
问题 I have two columns as below and I wanted to dynamically swap/change fxFlex value onClick of a button. I know that if you resize screen, fxFlex.md/lg etc will kick-in which I was able to accomplish. But am trying to understand how to change the fxFlex values on a static screen-size on some event like button-click. <div flexLayout="row"> <div fxFlex="fxFlexForCol1" style="background-color: green"> <button mat-raised-button (click)="swapViewableArea()">Click to enlarge view {{fxFlexForCol1}}<

Angular 5 Component input function that takes parameters

有些话、适合烂在心里 提交于 2020-07-04 11:35:48
问题 In an Angular 2+ component, how do I pass in a callback function that takes parameters? My initial assumption was something like <app-example [onComplete]="doThing('someParam')"></app-example> And sometimes I won't need any parameters, like this: <app-example [onComplete]="doSomeThingElse()"></app-example> And then in the component I have import { Component, OnInit } from '@angular/core'; @Component({ selector: 'app-example', templateUrl: './example.component.html', }) export class

Angular 5 Component input function that takes parameters

和自甴很熟 提交于 2020-07-04 11:33:28
问题 In an Angular 2+ component, how do I pass in a callback function that takes parameters? My initial assumption was something like <app-example [onComplete]="doThing('someParam')"></app-example> And sometimes I won't need any parameters, like this: <app-example [onComplete]="doSomeThingElse()"></app-example> And then in the component I have import { Component, OnInit } from '@angular/core'; @Component({ selector: 'app-example', templateUrl: './example.component.html', }) export class

Angular 5 Component input function that takes parameters

落花浮王杯 提交于 2020-07-04 11:31:37
问题 In an Angular 2+ component, how do I pass in a callback function that takes parameters? My initial assumption was something like <app-example [onComplete]="doThing('someParam')"></app-example> And sometimes I won't need any parameters, like this: <app-example [onComplete]="doSomeThingElse()"></app-example> And then in the component I have import { Component, OnInit } from '@angular/core'; @Component({ selector: 'app-example', templateUrl: './example.component.html', }) export class