Importance of ELVIS Operator(?.) in Template HTML File Using Angular Framework.

Chandan Luthra Aug 18th, 2020

ELVIS Operator can be used to check “undefined” on keys/fields/properties in html template file, Its means when you access keys in objects. And in object, some keys may be available or not. like Example.

results :
{
“name” : “Mohan”,
“emailId” : “mohan563@gmail.com”,
“gender” : “male”
}

Suppose, I want to access “emailId” key in template html file of an Angular project, for e.g “results.emailId“, here “results.emailId” key is always available in JSON object then its not compulsory use to ELVIS Operator. But in case the keys does not exists then ELVIS Operator comes to rescue us by applying a safe referencing to the JSON object e.g. “results?.emailId“. The “?.” operator allows to use the JSON keys that are not present. It will results in a “null” value.

Pravin kumar

pravin(d0t)kumar(at the rate)enveu(d0t)com

Chandan Luthra - Director, Product Engineering, Enveu
Chandan Luthra is a co-founder of Enveu, and heads the Engineering department at Enveu. He is an early adopter of OTT tech and has been part of many OTT platforms across the globe. He is developing & building Products and SaaS platforms for more than 13+ years

Add a Comment

Your email address will not be published. Required fields are marked *

Looking for Streaming Solutions?

  • Go-Live on 12+ platforms
  • Zero Revenue Share
  • Multiple Monetization Models
  • 50+ Integrations

get a demo today

Take control of your digital media strategy.
Contact us for a no-obligation demo of the Experience
Cloud, tailor-made for you!

    By Continuing, you agree to our Terms & Conditions and Privacy Policy