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 }; <h1>stu2 name {{stu2!.name}}</h1> // stu2 name <h1>stu2 id {{stu2!.id}}</h1> // 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; <h1>stu3 id{{stu3?.id}}</h1> // stu3 id <h1>stu3 name{{stu3?.name}}</h1> // 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!