Posts by Eduardo Vargas • 3,413 points
194 posts
-
0
votes1
answer312
viewsA: Karma unit tests (typescript/angular)
If your task is an array of type task would be something like this: it('should create tasks forms', async () => { component.task = [...task]; component.createTasksForms();…
-
1
votes1
answer270
viewsA: Unit Karma Test for Typescript/Angular Method
it('should select a task', () => { const obj ={ select: function()=>{} } const getElementById = spyOn(document, 'getElementById').and.returnValue(obj); const select = spyOn(obj, 'select');…
-
2
votes2
answers291
viewsA: Is it possible to pass a formgroup to the parent component?
in that case it seems better to use viewChild. @ViewChild('child') childComponent: childComponent; submitForm(){ console.log(childComponent.form); }
-
0
votes4
answers431
viewsA: Dynamically change class
Try it this way: <p [ngClass]="{ 'text-danger': redName, 'text-light': !redName }" >
-
-2
votes2
answers233
viewsA: Help - result.foreach is not a Function
Try it this way: this.service.obterTodos() .subscribe((response:any)=> { response.result.forEach(element => { this.usuComponent.push(element); }); });…
angularanswered Eduardo Vargas 3,413 -
1
votes1
answer741
viewsA: How to change font in an Angular project?
in your style.scss file @import url("https://fonts.googleapis.com/css?family=Roboto"); * { font-family: "Roboto", sans-serif; -webkit-appearance: none; -moz-appearance: none; appearance: none; }…
angularanswered Eduardo Vargas 3,413 -
1
votes1
answer235
viewsA: Data Return with Angular
Try it this way: {{dificuldade|async}} if pq difficulty is an observable and not your data itself.
-
1
votes2
answers791
viewsA: Formgroup does not take default values
you have to set the value through typescript: this.cadastroForm.setValue(seuJson);
-
0
votes1
answer622
viewsA: Primeng p-editor error in Angular 7
According to the documention you have to install the Quill separately Quill Editor 1.0. npm install quill --save Add Quill to in angular-cli.json scripts "scripts": [...…
-
1
votes2
answers1648
viewsA: Angular error: Staticinjectorerror(Appmodule) for Activatedroute
Do it like this: // private route: ActivatedRoute constructor(private route: ActivatedRoute ) { }
-
1
votes2
answers124
viewsA: Unit tests for Pipe tap() in Angular
normally tap tests itself just by giving a subscribe on the observable. but as in your case is an event is a little more complicated. I would do so: const spy = jest.spyOn(SeuComponent,…
-
2
votes1
answer154
viewsA: Primeng - Search multiple fields in Picklist
Does without spaces: filterBy="brand,year,color"
-
1
votes1
answer23
viewsA: Model copular only with model data at angular
Follow an example: recuperarCliente() : Observable<ClienteState> {//Gosto de usar state no final de entidades que contem o estado da aplicação return…
-
1
votes1
answer874
viewsA: Angular 7: How to update the html variable automatically when its value is changed in the . ts file?
Try to change the reference of your pro angular array to know that something has changed. this.itens=[...this.itens,item]
-
0
votes2
answers2209
viewsA: How to Extend/Inherit Angular2 Component?
It’s like you have an abstract class that would be this base class. It doesn’t necessarily have to be a component, but it can implement lifecycles like init and such. Within it you can have common…
-
0
votes3
answers155
viewsA: How do I catch a backend error and not log into the application?
The best would be your backend return 501 which is the default for unauthorized and you handle the catch error as you had done.
-
0
votes1
answer1326
viewsA: Nullinjectorerror: No Provider for Formcontrol! Error in simple form with Reactiveforms
Try it like this import { Component, OnInit } from '@angular/core'; import { FormGroup, FormBuilder, FormControl, RequiredValidator, Validators } from '@angular/forms'; @Component({ selector:…
-
0
votes1
answer39
viewsA: How to use a direct Html tag on my object?
First you have to separate your string into an array of substrings based on something. For example by spaces: meuArray:string[] ngOnInit(){ teste = {nome: "primeiro item segundo item terceiro item"}…
-
0
votes1
answer26
viewsA: Returning Array[] with Obsevable
If you have used Httpclient do so: getPessoas(): Observable<Pessoa[]> { return this.http.get<Pessoa[]>(this.baseUrlService); }
-
1
votes1
answer85
viewsA: How to show a loading only on the element on which it was clicked
Do it like this: this.notificacoes= notificacoes.map(obj = > { obj.loading=false; return obj; }); testaLoadingExclusao(notificacao){ notificacao.loading = true; } and in html <div *ngFor="let…
-
1
votes1
answer48
viewsA: Start radiobutton with checked using Reactiveforms + Formarray
Try it this way: createFormGroup(produto?: any, indice?: number): FormGroup { return this.fb.group({ id_atributo_principal: new FormControl(true, [Validators.required]), }); } }…
-
0
votes2
answers113
viewsA: Problems with Reactiveforms at Angular
do so: export class ServicosComponent implements OnInit { servicos: Servico[]; searchForm: FormGroup; get search(){ return this.searchForm.get('searchControl'); } constructor(private…
-
2
votes1
answer747
viewsA: Interceptor not triggered - Angular 7
Fabricio seems that the problem is that you are using http instead of http client First remove Httpmodule from your main module. And in your service: import { Httpclient } from…
-
1
votes1
answer55
viewsA: There is performance difference using ngIf directly on a component
Both have the same performance ngIf is a structural directive so it generates an ng-template around the element you place it and manipulates the gift accordingly. Thus in no case does it instantiate…
-
1
votes1
answer288
viewsA: First always empty input in Formgroup
The problem is that formGroup is undefined until its answer. Either you use ngIf or initialize the empty form in init. <form *ngIf="formGroup" [formGroup]="clienteForm" (ngSubmit)="salvar()">…
-
1
votes3
answers426
viewsA: Problems with Angular Material
Import the module instead of redeclaring the material component. import { MatDialogModule } from '@angular/material/dialog'; @NgModule({ declarations: [ AppComponent, HeaderComponent,…
angularanswered Eduardo Vargas 3,413 -
4
votes1
answer379
viewsA: Block weekends in the Angular Material datepicker
<mat-form-field> <input matInput [matDatepickerFilter]="myFilter" [matDatepicker]="picker" placeholder="Choose a date"> <mat-datepicker-toggle matSuffix…
-
0
votes1
answer52
viewsA: Repeating structure that adds elements in an array without repeating elements
With es6 and using Set a much more elegant solution is possible. produtosConfirmadosAnuncio=new Set() adicionaProdutoConfirmadosAnuncio(){ this.produtosConfirmadosAnuncio=new…
-
2
votes1
answer1003
viewsA: 404 error while updating page - Angular 4
According to the documentation the default routes have to redirect pro index https://angular.io/guide/deployment#routed-apps-must-fallback-to-indexhtml rewrite . htaccess RewriteEngine On # If an…
-
1
votes1
answer137
viewsA: Uikit with interpolation in Angular 7
At the angle to set a property of an html or component based on a property of your ts just use brackets instead of the normal property. Directive differences in Angular <progress…
angularanswered Eduardo Vargas 3,413 -
1
votes1
answer226
viewsA: ngModel validation does not work in select field
required only works in select if the value of the first option is "" <select required #selecttipoproduto="ngModel" (change)="setTipoProduto(tipoDoProduto)" [(ngModel)]="tipoDoProduto"…
-
-2
votes2
answers225
viewsA: Get Access Token in Ionic
pegarToken(){ const auth = btoa(`${this.clientId}:${this.clientSecret}`);//substitui pelo seu id e secret return `Bearer ${auth}`; } getPayment() { let token =…
-
2
votes1
answer102
viewsA: How can I shape the object generated by Frombuilder?
The best would be for every chained object you have. You create another formGroup inside your formGroup so it gets the structure the way you need it. this.formRegister = this.formBuilder.group({…
-
2
votes1
answer886
viewsA: Grab id of the button clicked on Angular
each ref must be unique, try: <div class="col-sm"> <button type="button" class="btn btn-primary bot-click" value="E" id="E" #ref1 (click)="but_no(ref1.value)">CASA FECHADA</button>…
-
1
votes1
answer277
viewsA: Check http status at the angle
Do it like this: this.http.post (this.url,json, {observe: 'response'}) .subscribe ( res => { console.log(res); console.log(res.status); }, (err: any) => { console.log('raw error =>', err);…
-
3
votes1
answer143
viewsA: Reactive validation at angular with formgroup
First you don’t need the Compose. this.formularioLogin = this.fb.group({ email: ['',[Validators.required, Validators.email]], password: ['', [Validators.required]], }); Tries: <mat-error…
-
0
votes1
answer1261
viewsA: How to change the CSS of primeNG components in Angular?
You have to use ::ng-deep :host /deep/ p-menubar { background-color: olivedrab; font-size: 14px; } Official documentation view Encapsulation:…
-
1
votes1
answer29
viewsA: Filter number of items with a certain property
You can use the method filter arrays ngOnInit() { this.bugsService.bugLists() .subscribe(response => { this.bugList = response this.bugsAbertos=this.bugList.filter(bug=>bug.status==='aberto')…
angularanswered Eduardo Vargas 3,413 -
1
votes1
answer162
viewsA: Angular 7: Biding an object that will receive a json from an HTTP GET
You have to map your api response template to your application’s internal state model, for this the best is to use the map operator: http.get<Endereco>('url') .pipe( map(resposta=>{ return…
-
0
votes3
answers824
viewsA: Angular 7 - Reactive Form update template
To create Form the way you’re doing is right. To get the value of the form you can use the spread Operator of the es6. onSubmit(){ this.telefone= {...this.telefoneForm.value, ...this.telefone}; }…
angularanswered Eduardo Vargas 3,413 -
0
votes1
answer59
viewsA: Problems with requests in Angular
Note that in your methodSubmit you expect an ngForm and when you call it in html vc is not passing anything. <form #clienteform="ngForm" (ngSubmit)="onSubmit(clienteform)">…
-
1
votes1
answer34
viewsA: Repeat structure does not work when my object is copied without reference
Man not the cutest way but so it works: var minhaVar = JSON.parse(JSON.stringify(obj));
-
0
votes1
answer3862
viewsA: ERROR Error: Cannot find a supporting differ Object '[Object Object]' of type 'Object'. Ngfor only Supports Binding to Iterables such as Arrays
you have to map your answer to the array. return this.http.get<any>(this.API) ou cria um model tipo ProgrammingResponse .pipe( map(response=>response.result.times) tap(console.log) ) Edit…
angularanswered Eduardo Vargas 3,413 -
1
votes1
answer40
viewsA: How to limit subscribe to just one loop
You can use the operator take https://www.learnrxjs.io/operators/filtering/take.html router.events.pipe(take(1)).subscribe((val) => { alert(val); });…
-
1
votes1
answer263
viewsA: Console error: Can’t bind to 'formGroup' Since it isn’t a known Property of 'form'
This error usually occurs when you forget to import the Reactiveformsmodule in the module that you have left your component
-
0
votes1
answer352
viewsA: Http Post in Angular
If you use pipe do not need point before map. .post('https://httpbin.org/post', JSON.stringify(this.formulario.value)).pipe (map(res => res))
-
0
votes1
answer381
viewsA: Take Angular Datepicker value
You can do it like this: this.seuForm.get('serializedDate').value
-
1
votes1
answer3539
viewsA: Change CSS property in Typescript (Angular)
If you are going to change a property you can use ngStyle if you are more than one you can use ngClass take a look at the stackblitz that I created: https://stackblitz.com/edit/angular-ohu5kw TS…
-
2
votes3
answers1021
viewsA: Customized Angular 2/4 validator
Change your function to: static cpf(control: AbstractControl): { [key: string]: any } { console.log(control.value); if (control.value !== '000.000.000-00') { return {cpfInvalido: 'valor recebido:…
angularanswered Eduardo Vargas 3,413 -
0
votes1
answer32
viewsA: items Hidden by Filters - error console
Try pressing with the right button on the console >filter >unhide all https://i.stack.Imgur.com/aTJRe.png…