Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

114
Views
Operador coalescente nulo angular 2

¿Cuál es el equivalente del operador coalescente nulo (??) en angular 2?

En C# podemos realizar esta operación:

 string str = name ?? FirstName ?? "First Name is null";
about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

La fusión se realiza a través de || operador, es decir

 let str:string = name || FirstName || "name is null and FirstName is null";

También puede leer esta pregunta para obtener más detalles y explicaciones.

about 4 years ago · Santiago Trujillo Report

0

En mecanografiado

Typescript introdujo la fusión nula con la versión 3.7 , por lo que si está ejecutando en 3.7 o superior, simplemente puede escribir:

 const str = name ?? firstName ?? "Name and First Name are both null"; const x = foo?.bar.baz() ?? bizz();

Consulte https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#nullish-coalescing .

En la Plantilla Angular

Desde Angular 12 también puedes usar ?? en la plantilla.

about 4 years ago · Santiago Trujillo Report

0

Tal vez lo que quieres lograr es esto:

 let str = typeof (name) !== 'undefined' && name !== null ? name : typeof (FirstName ) === 'undefined' || FirstName === null ? "First Name is null" : FirstName
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!