Tag : javascript

I have the following interceptor … note that I’m not doing anything of interest since I’m trying to debug my issue: import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from "@angular/common/http"; import { Injectable } from "@angular/core"; import { ApiService, IUserInfo } from "base-core"; import { from, Observable, of } from "rxjs"; import { map, mergeMap, ..

Read more

I have two functions inside ngOnInit. ngOnInit(): void { this.getUserInfo(); this.getUserFeed(); } I want to run the first function first and use the value of first in order to execute second. public getUserInfo() { return this.userFeedService.getShowdaUserInfo().subscribe( (response: any) => { this.userId = response.id; }); } public getUserFeed() { return this.userFeedService.getShowdaUserFeed(this.params, this.userId).subscribe( (response: any) => { ..

Read more

So i have a textArea, and i can’t let the user type ‘%’ on it; to handle this problem i did the following: html: <div class="col-12 col-xs-12 col-sm-12 col-md-6"> <div class="col-md-12 label-base"> <label for="exampleFormControlTextarea1">Justificativa</label> <textarea style="resize: none" ng-disabled="negociacaoEspecCtrl.proposta.flagDesabilitaEdicaoProposta" class="form-control observacoes" id="exampleFormControlTextarea1" rows="3" ng-model="negociacaoEspecCtrl.proposta.dadosCadastro.negociacaoEspecial.justificativaNegociacaoEspecial" onkeypress="test()"> </textarea> </div> </div> The function inside my controller: $scope.test = function ..

Read more

So I’ve created a directive for resizing images. Basically it works – I’m getting the Base64 string that is resized image (I’m testing this using this page: https://codebeautify.org/base64-to-image-converter) Lets go to the code: changeEvent(imageResult: ImageResult) { const dataURL = imageResult.resized && imageResult.resized.dataURL ? imageResult.resized.dataURL : (imageResult.dataURL ? imageResult.dataURL : null); if (!dataURL) { return; } ..

Read more

All code you can find here: https://stackblitz.com/edit/angular-expample?file=src%2Fapp%2Fapp.component.html I have a problem formatting the array I’m loop through. Main logic function is this: this.allFilters.push( Array.isArray(val.value) ? { name: val.name, value: val.value.map((obj: any) => obj.value).join(" – "), displayName: val.displayName, displayValue: val.value.map((obj: any) => obj.value).join(" – ") } : { name: val.name, value: val.value, displayName: val.displayName, displayValue: val.displayValue ..

Read more

I have a component composed of multiple sub component, each of them will have a @HostListener(‘document:keydown’, [‘$event’]) handleKeyboardDownEvent($event: KeyboardEvent): void { if($event.key===this.keys.includes($event.key)) … } how can I write a unit test who will simulate a press on a specific key ? I’ve tried: const keyboardEvent = new KeyboardEvent(‘keydown’, {key: ‘e’, code: ‘e’, ctrlKey: true}); fixture ..

Read more

I have below 3 objects listed below with data. I want to find const oldData.data.parameter_value = b and oldData.data.label_value = b inside each object of const newData.selected_parameter_value. And if value exist in newData array, then replace all newData.selected_parameter_value.parameter_value = b and newData.selected_parameter_value.label_value = b , with const updatedData.data.parameter_value = red and const updatedData.data.label_value = red. ..

Read more