I am very new to the Ionic Framework, Angular JS and TypeScript but trying to improve as fast as possible.
But now I encountered a problem I can’t seem to solve, not even using Google
So I was just trying a simple Input function.
This is the relevant part of my .html file:
Instructional text that shows before the input has a value.
So once the input has a value (which it does when you bind [ngModel]), the placeholder attribute is ignored. <ion-input> is expecting its ngModel to be a string, and if it isn’t, it tries to coerce it into one, and Object-to-string coercion on your var1 of {} which is an Object results in “[object Object]”.
Thanks for the quick answer, I see the problem.
So do you know of an easy way to only bind [(ngModel)] once you click the Login Button, while still being able to get the input? I was trying out a few things but couldn’t find an easy workaround.
No, and I can’t even make any sense out of that. If what you are trying to achieve is changing what appears in the input control before the user starts entering anything into it, you have two options, both of which need var1 to be a string and not an object:
Option 1: simply prime the backing property
var1 = "placeholder text can go here";
<ion-input [(ngModel)]="var1"></ion-input>
Option 2: placeholder will do its job if the bound property is an empty string:
var1 = "";
<ion-input [(ngModel)]="var1" placeholder="placeholder text can also go here"></ion-input>