In HTML, the common way to deactivate an input field is by using the disabled attribute:
Check out this link for more information.
For example:
<form action="/submit_form.php">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname" disabled="disabled"><br>
<input type="submit" value="Submit">
</form>
The function PreventDefault does not disable an input field as far as I know. Although theoretically MaxLength could be used, it may not clearly indicate the purpose of the code.
The disabled attribute can be dynamically controlled in Angular just like any other attribute. For instance, you can use something like [disabled]="shouldDisable()"
where shouldDisable()
is a method that returns true or false.
While ion-input may have unique functionalities, I am not familiar with them. More details are available here: Learn more about disabling ion-input here.