Answer the question
In order to leave comments, you need to log in
What does "?" mean? in the user?.name entry (question to question ->)?
I saw this code in the manual:
@Component({
selector: 'my-app',
template: `<div>
<p>Имя пользователя: {{user?.name}}</p>
<p>Возраст пользователя: {{user?.age}}</p>
</div>`,
providers: [HttpService]
})
Answer the question
In order to leave comments, you need to log in
Alexander Belov 's
answer is not accurate.
There is no check for the presence of name or age, it is checked if user != null, otherwise user cannot contain any parameters at all.
those. user?.name can be "decomposed" into user==null?'':user.name
without this, there will be an error:
user = null
user.name
VM111:1 Uncaught TypeError
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question