Home>Article>Web Front-end> What are the uses of "?" and "!" in Angular?
Related tutorial recommendations: "angularjs tutorial"
?
Used When checking whether the variable before the question mark is null or undefined, the program will not make an error.
stu2: Student = { id: 1, name: undefined, age: 3 };stu2 name {{stu2!.name}}
// stu2 namestu2 id {{stu2!.id}}
// stu2 id 1
!
Used to check that the program will not make an error when the variable after the exclamation mark is null or undefined.
stu3: Student;stu3 id{{stu3?.id}}
// stu3 idstu3 name{{stu3?.name}}
// stu3 name
For more programming-related knowledge, please visit:Introduction to Programming! !
The above is the detailed content of What are the uses of "?" and "!" in Angular?. For more information, please follow other related articles on the PHP Chinese website!