angular5

How to call multiple methods on a button click using Angular 5?

余生长醉 提交于 2020-03-18 11:14:18
问题 i am using angular 5 and facing a problem. i want to submit (click) event and call two or multiple method one bye one. Please give me idea or solution so that i can submit a (click) event and call two or multiple method. such as .html file <button (click)="abc(); bcde()"></button> .ts file first method abc(){} second method method bcde(){} is this a right way to do this. Please suggest me and help me to solve this 回答1: <button (click)="callall()"></button> make one function and call all the

Expected validator to return Promise or Observable

放肆的年华 提交于 2020-03-17 04:25:46
问题 Im trying to do a custom validation on Angular 5 but I'm facing the following error Expected validator to return Promise or Observable I just want to return an error to the form if the value doesnt match the required, heres my code: This is the component where is my form constructor(fb: FormBuilder, private cadastroService:CadastroService) { this.signUp = fb.group({ "name": ["", Validators.compose([Validators.required, Validators.minLength(2)])], "email": ["", Validators.compose([Validators

Mat select click outside not working, when drop down close

房东的猫 提交于 2020-03-16 06:11:05
问题 I have drop down made with Mat select angular component, I need to trigger an event when I clicked outside of the drop down (body of the page). <mat-select #select multiple (change)="onSubmit($event)" [(ngModel)]="emp"> <mat-option *ngFor="let value of filter.default" [value]="value"> {{value}} </mat-option> </mat-select> Here is my ts file export class AnotherComponent { public text: String; @HostListener('document:click', ['$event']) clickout(event) { if(this.eRef.nativeElement.contains

Angular 2+ - Tree table using API

 ̄綄美尐妖づ 提交于 2020-02-25 04:03:50
问题 I have three Apis for categories,subcategories and policies. For eg: "https://restapi.com/project". 1. Category In the case of category, I have to pass the body(raw data) as above json for the above Api { "startIndex":"1", "count":"150", "groupBy":"category", "searchTerm":"PROJECT:project1" } Api Response : Listed out all categories { "data": [ { projectName:null, categoryName: category1, subCategoryName:null, controlName:null }, { projectName:null, categoryName: category2, subCategoryName

Issue with Tab index for Prime ng datatables sort icon

你离开我真会死。 提交于 2020-02-06 07:56:08
问题 I've used the prime ng data table in my application. In that, I want to use tab index for sort icon( <p-sortIcon> ) but it's not working. can anyone help me with this?? this is how I used in code image And displaying as below, once I enter tab, got focus there but I'm unable to do sorting using the keyboard. image 回答1: Try this friend. [attr.tabindex]="1" 回答2: why dont you go with primeng default modules.... https://primefaces.org/primeng/#/table/sort 来源: https://stackoverflow.com/questions

Issue with Tab index for Prime ng datatables sort icon

烂漫一生 提交于 2020-02-06 07:56:07
问题 I've used the prime ng data table in my application. In that, I want to use tab index for sort icon( <p-sortIcon> ) but it's not working. can anyone help me with this?? this is how I used in code image And displaying as below, once I enter tab, got focus there but I'm unable to do sorting using the keyboard. image 回答1: Try this friend. [attr.tabindex]="1" 回答2: why dont you go with primeng default modules.... https://primefaces.org/primeng/#/table/sort 来源: https://stackoverflow.com/questions

Angular 5 solely validation on blur?

杀马特。学长 韩版系。学妹 提交于 2020-02-03 05:11:46
问题 I wonder if it is possible to have the validation in reactive forms on blur. At the moment you can set updateOn: "blur" but then the values of the input fields won't update on input. In my case i need the values to be updated on every keystroke because I do calculations with it and show the result to the user. The validation should only happen on blur. thx. EDIT: I use FormBuilder, some build in validators and some custom validators. Example code: let formToMake = { purpose: [null, Validators

Angular 5 - sanitizing HTML with pipe

烈酒焚心 提交于 2020-02-02 02:34:06
问题 When i got the warning: "WARNING: sanitizing HTML stripped some content" I did some research and saw people using the pipe below or a pipe that looks like the one below import { Pipe, PipeTransform } from "@angular/core"; import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; @Pipe({ name: 'sanitizeHtml' }) export class SanitizeHtmlPipe implements PipeTransform { constructor(private _sanitizer:DomSanitizer) { } transform(v:string):SafeHtml { return this._sanitizer

Angular 5 - instantiate a component from its name as a string

。_饼干妹妹 提交于 2020-01-30 04:47:11
问题 I know how to init components using ComponentFactoryResolver.resolveComponentFactory(AComponentType) but the method expects a Type , while in my code I have the name of the type as a string . In the Angular API is there a method to resolve by string ? If not, how can I convert a string to a Type in TypeScript? In case that none of the above is possible I will resort to a map but it's not so straightforward as the components I need to instantiate will come from remotely fetched UMD angular

Read response headers from API response - Angular 5 + TypeScript

為{幸葍}努か 提交于 2020-01-26 04:58:48
问题 I'm triggering a HTTP request and I'm getting a valid response from it. The response also has a header X-Token that I wish to read. I'm trying the below code to read the headers, however, I get null as a result this.currentlyExecuting.request = this.http.request(reqParams.type, reqParams.url, { body: reqParams.body, responseType: 'json', observe: 'response' }).subscribe( (_response: any) => { // Also tried _response.headers.init(); const header = _response.headers.get('X-Token'); console.log