The cons to this are if our Observable has multiple values we must manually unsubscribe with ngOnDestroy life cycle hook. You can use the return command twice, but them how do you have the variable that equals the function, change index for each variable. The pros to this are it’s simple and works well for single values. Click here to see the full demo with network requests. In C or C++, we cannot return multiple values from a function directly. Returning multiple values from a function using an array. Returning multiple values via arrays has a limitation wherein we can return multiple values of only the same type. Let's take a look at the following example: We can return more than one values from a function by using the method called “call by address”, or “call by reference”. Click here to check it out. Here is the code of greater than validator (gte) from the Custom Validators in Angular Reactive Form tutorial.The validator checks if the given value is greater than 10 and if not return ValidationErrors. Notice: I used Angular function names to help you understand what it really does. A function is a block of code that you can use multiple times in an application. function updates the img DOM element's src property with the current value of the srcURL variable. This article will provide example of how to call component function on button click event in angular 9/8 application. Most of the heavy lifting for creating reactive forms happens in the component class instead of the template (HTML file). Most of the time, there are some changes in our form controls, which are created using either FormGroup or FormControl. For example, if we want to return a string as well as integer, it won't be possible using the 2nd approach. If you want the function to return a value, you can use a data type (such as int, string, etc.)