Posts by Marcelo Vismari • 1,665 points
78 posts
-
0
votes2
answers54
viewsA: I’m creating a currency converter, and it returns a wrong value
The switch in Javascript does not allow multiple parameters of the way you encoded, separating the values in the case comma. Change the logic to if/else to be able to compare the value of 2…
javascriptanswered Marcelo Vismari 1,665 -
1
votes2
answers49
viewsA: How to remove ZIP code and country from a string
The expression below looks for 5 numbers in the sequence, a dash, 3 more numbers in the sequence and then everything in front. It may help but depending on the variation of your inputs you may need…
-
0
votes1
answer16
viewsA: I want to take the value of one form field and move on to another
You can use the event onchange to know when the input date is changed and can update the field with the day of the week. See in the example below: const inputData = document.querySelector('#data');…
-
1
votes1
answer47
viewsA: Array sum returns only one value
From what I understand the problem is because of the difference in the size of the array. Adjusting the size of the array can solve your problem without having to change what already exists, just by…
-
2
votes1
answer21
viewsA: Select a value depending on the chosen footage
I believe that reversing your logic slightly works the way you’re hoping: SELECT * FROM valor_metro WHERE 7 BETWEEN de_mt AND ate_mt http://sqlfiddle.com/#! 9/4e367a/1/0…
-
0
votes1
answer56
viewsA: Problems when receiving list of Storage values in a variable (Ionic)
When calling the function add() the browser will interpret line by line of this method. When he arrives at the this.checkProductTagStorage() he calls that function and he’s on to the next one line…
-
0
votes2
answers266
viewsA: Problem with reduce to calculate arithmetic mean of array
Looking at your code, length is spelled wrong (lenght). Fixing this the code starts working: var valores = [1.5, 2, 4, 10]; var media = valores.reduce(function (total, item, indice, array) { total =…
-
1
votes1
answer37
viewsA: API request at Angular
Rodrigo, to try to simulate his problem lacked some other excerpts. So I set a complete example that is working: Service import { Observable } from "rxjs"; import { HttpClient } from…
-
0
votes2
answers141
viewsA: How to group substrings in condition and return them with BASH_REMATCH
To meet the most critical, follow the conversion of the JS example to bash: str="python-zope-proxy-4.3.5-1-x86_64.chi.zst" pkg_re='^([a-z-]+)(-)([0-9\\.]+)(-)([0-9])(-)(.*)(.chi.zst)$' [[ $str =~…
-
0
votes1
answer95
viewsA: API query blocked by CORS
You can ask the API owner to include the key Access-Control-Allow-Origin in the response header with your domain address or a *. Example: Access-Control-Allow-Origin: http://seudominio.com or…
-
0
votes2
answers45
viewsA: Conflict in the use of Javascript functions
Diego, since you didn’t post all the code, I imagined how it could be and I think it’s working properly: const operation = document.querySelectorAll("[data-operation]"); const numbers =…
javascriptanswered Marcelo Vismari 1,665 -
0
votes3
answers81
viewsA: Help with code reduction in If/Else
To avoid several if/else I used an object opcoes accessing its properties through a variable opcoes[variavel]. To complement we remove all CSS classes mapped to the object opcoes and add only the…
-
1
votes1
answer41
viewsA: How to bring the unique values of a list array according to the newest Javascript date
let dados = [ ["09/01/2020", "JOAO"], ["13/01/2020", "PAULO"], ["23/01/2020", "JOAO"], ["01/01/2020", "JOAO"], ["01/01/2020", "PAULO"], …
-
2
votes2
answers112
viewsA: Dynamic CSS in backgorund-color
One of the alternatives to not creating 3 equal classes is to create CSS classes that are applied only when used in conjunction with .card_head. Each class of these will only take the…
-
2
votes1
answer187
viewsA: How do I update my package dependencies without publishing a new version of my package?
In your example where the package [email protected] package-dependent [email protected] the package.json file of the package B should look like the following: { "name": "B", "version": "1.0.0", "dependencies": { "A":…
npmanswered Marcelo Vismari 1,665 -
0
votes3
answers48
viewsA: Problem with target identification
Remember that the browser will interpret your script only once. So when the browser goes through the line var a1 = document.getElementById('a1').innerHTML, the value of a1 is empty. This empty value…
javascriptanswered Marcelo Vismari 1,665 -
0
votes2
answers69
viewsA: Form not returning Angular data
The problem is in your template. Note that the data that appears in the console is lowercase (Cpf, email, etc.) and in your template are uppercase: Change of : <td>{{c.NOME}}</td>…
-
0
votes1
answer92
viewsA: Calculate birthday date in typescritp
Since I don’t know your component msp-input-text I’ll leave an example using a input: Template: <!-- Sempre que o usuário alterar a data ativamos a função setData --> <!-- Neste exemplo…
-
1
votes3
answers129
viewsA: Recursion - add numbers to an array
See that every time the countup is called within himself, the interpreter waits until the function returns a value so that it can continue executing the code. To facilitate understanding follow the…
-
2
votes2
answers695
viewsA: How to apply a *ngFor to an array of objects in Angular where the name varies?
You can use Keyvaluepipe to read the properties of the object and make an iteration. See the example below: Class: import { Component } from "@angular/core"; @Component({ selector: "my-app",…
-
3
votes1
answer545
viewsA: How to change HTML via Typescript (Angular 2)?
Weslipe, I made some adjustments using a bit of Rxjs. See below the code: Template <div>{{frase}}</div> Class import { Component, OnInit } from '@angular/core'; import { from, of } from…
-
0
votes2
answers141
viewsA: How to remove elements from a javascript list
document.getElementById('btnGerar').addEventListener('click', () => { let numero = window.document.getElementById('numero'); if…
-
0
votes4
answers1265
viewsA: Request JSON (http post) with Angular 2+
I tried to simulate your problem but could not, the code below worked perfectly (tested in Stackblitz): import { Component, OnInit } from '@angular/core'; import { HttpClient, HttpHeaders } from…
angularanswered Marcelo Vismari 1,665 -
0
votes1
answer102
viewsA: Checkbox with checked property does not return me any value
To catch the value and the checked of your input[type=checkbox] amend the following content of (click)="addCheckbox(checkbox.value)" for: (click)="addCheckbox($event.target)" and change the method…
-
1
votes1
answer99
viewsA: Handle HTTP Request with Item Array as response
You can make two loops, one to list the plan name and one to list the packages. To treat the price display with or without discount just use a very simple logic with the *ngIf (do not forget to…
-
0
votes1
answer552
viewsA: Calling a javascript function in ejs files
It is necessary to pass the function reference to the View context. You can pass the function as a parameter in the same way you send data to the View, for example: res.render('myView', { formatDate…
-
0
votes4
answers259
viewsA: Error While Consuming Api at Angular
The problem is because the variable pokemon is undefined during the rendering of your template. Note that although you trigger your API to fill this variable, completing the request takes a certain…
-
4
votes1
answer132
viewsA: Is using ID as a global variable a good practice in JAVASCRIPT?
Access the element from the first way (specification link) may generate some conflicts of the type: console.log(typeof teste); console.log(typeof (document.getElementById('teste'))); <div…
-
1
votes2
answers45
viewsA: Angular Compomente Personalized emitEvent: false
After the loading of your form is issued a single event for the lastName who writes a message on the console: event.last.name Reis This is because your second input is a custom component…
angularanswered Marcelo Vismari 1,665 -
1
votes2
answers619
viewsA: It is possible to return a Observable<Boolean> from the get request
After making the request through the method get, use within the pipe one map to check if the status returned is zero by projecting a boolean value. Next use a catchError returning of(false) to…
-
0
votes1
answer216
viewsA: Export modules at angular 8
The problem is that you declared and exported the module itself AmbevModuleModule. Just adjust the declarations and the exports for the component AmbevComponentComponent: import { NgModule } from…
angularanswered Marcelo Vismari 1,665 -
1
votes1
answer74
viewsA: Duplicate Data Loop Query Nodejs
It was not clear what the problem is. Analyzing the code we can improve some things and suddenly your problem can be solved: Avoid using global variables as you did with i and dadosMsg. Inside the…
-
2
votes1
answer83
viewsA: How to store a variable in a specific chunk of the template?
As the staff commented, starting this processing in the template is not the most indicated but focusing on your question directly you could do as follows: <div *ngFor="let objeto of objetos">…
angularanswered Marcelo Vismari 1,665 -
1
votes2
answers194
viewsA: Feedback a observable Boolean method
The checkPermission will only invoke the content within your subscribe when it completes the task that has been delegated to it, for example a request. See that it is an asynchronous process, then…
-
0
votes2
answers65
viewsA: Why do I get a blank page instead of redirecting like this in the command (header: Location)?
Andre analyzing the posted content can see that missed you invoke the function login_admin. It exists but at no time is called to authenticate and create cookies if successful. See the settings…
-
0
votes2
answers417
viewsA: Axios falls in catch even with status code 200
If you are using the async\await it is not necessary to use the resolve\reject. Try modifying your code to: // ... try { const dados = await api.post('/login', { email, password }, { headers: {…
-
1
votes4
answers9163
viewsA: How to refresh the screen in Angular?
From what I understand your second code is working, since you posted the result of the console. So after making the first refresh he stops there since the sessionStorage.refresh has the value false.…
angularanswered Marcelo Vismari 1,665 -
3
votes1
answer94
viewsA: Tag <head> <body> in Angular projects
When you create an Angular project, by default inside the folder src has a file called index.html. This file basically contains the structure you quoted, head, body and some other items. This file…
-
3
votes2
answers1797
viewsA: Adding spaces in Javascript
A padStart can help you: function escada(numeroDegraus) { for (let i = 1; i <= numeroDegraus; i++) { console.log('#'.repeat(i).padStart(numeroDegraus, ' ')); } } escada(5); Another option without…
javascriptanswered Marcelo Vismari 1,665 -
0
votes2
answers37
viewsA: It is returning the data below 2000, but I need to know what positions this data is in. Javascript
You can pass a second parameter in the function that is passed as parameter in the filter to pick up the index. Example: const veiculos = [9999, 1000, 2000, 3000, 4000, 5000]; const indexes = [];…
javascriptanswered Marcelo Vismari 1,665 -
0
votes3
answers1466
viewsA: Typeerror: Cannot read Property 'filename' of Undefined
Horacio, the example below is a code that I wrote a while ago and that works correctly. I removed some points that are not part of the understanding. Another point is that if working with Array the…
-
0
votes1
answer811
viewsA: Angular Integration with Pagseguro
Define or not the items you quoted within your headers It will make no difference when consuming the API. The API is who should send these items in the response header so the browser knows what the…
angularanswered Marcelo Vismari 1,665 -
1
votes1
answer558
viewsA: How does the "next" function work in Angular?
By instantiating a Subject it is necessary to state what kind of data will work, for example: new Subject<number>();. In your example the type of object that the Subject will work is an object…
-
1
votes2
answers373
viewsA: Control div from a checked checkbox
This is a very simple example that renders some checkboxes. By clicking on the checkbox the value of the field selecionado inside the array listaProcesso is updated. When updated this value is…
-
3
votes1
answer51
viewsA: How to use multiple repository sources with priority in NPM?
So far it is not possible, according to the documentation. I have also read a lot of the documentation in search of this solution. A possible solution is to use the Nexus as local NPM repository and…
npmanswered Marcelo Vismari 1,665 -
1
votes1
answer377
viewsA: Send jwt in header by GET
In the same way you indicate the Content-type it is possible to indicate a Authorization (for example): // (...) headers: new Headers({ 'Content-Type': 'application/json', 'minha_chave':…
-
2
votes1
answer385
viewsA: How to remove property inherited by the component?
You can override CSS classes to change the desired properties. Suppose there is a class called .a { height: 100px; }, declare in another CSS file the same class by changing its properties, e.g..: .a…
-
1
votes3
answers147
viewsA: Delete copied array item without deleting the item from its source - Vuejs
Rodolfo this is because the Array is a referenced type (Reference type). When you say that listaClone = listaOriginal both variables point to the same array. To solve use a spread to clone…
-
1
votes2
answers75
viewsA: Insert random elements into a Java Script array
A loop will solve your problem since the items inserted in the array are in different positions: const arr = [1, 2, 4, 5, 7] // Adicione a [[posição1, valor1], [posição2, valor2]...] const data =…
javascriptanswered Marcelo Vismari 1,665 -
0
votes2
answers87
viewsA: Centralize login and password fields
One of the ways to center it is by using the text-center in the <body> exactly as in the example own website of bootstrap: <body class="text-center"> <form class="form-signin">…