Change ionic title dynamically when user want - ionic-framework

I need to change for "my items", User should be able to change "title"
I already try
<ion-input type="text" (ngModel)="Item.title"></ion-input>
Error : Uncaught TypeError: Object(...) is not a function

Please Try this.
<ion-input type=“text” [(ngModel)]=“Item.title”></ion-input>

Related

when i click enter login form should submit in ionic 4

am developing a web application in ionic. I have a login form. If I click the login button form is submitting and working fine. Now I am looking for after entering the email and password i click enter button then the form should submit. If i click the enter button form should submit. Here is the code.
<form [formGroup]="loginForm">
<ion-item>
<ion-input type="email" required class="textWidth" formControlName="email" placeholder="Email id"></ion-input>
</ion-item>
<ion-item>
<ion-input type="password" class="textWidth" formControlName="password" placeholder="Password"></ion-input>
</ion-item>
<div class="text-center">
<ion-button type="submit" (click)="Login()" class="signinButton">Sign in</ion-button>
</div>
</form>
Can you please help me with this?
Thanks & Regards
You can use it
(keyup.enter)="onSubmit(loginForm.value)"
Move the (click)="login()" function to the form like this (ngSubmit)="login()"
This should trigger the function on pressing the enter key if there is no other form.

Trigger ion-input focus when ion-icon clicked

Good day all
I am building my first ionic 4 mobile application, and have a question about how label, icons and other elements can be connected to a form input.
In normal HTML forms you have a relationship between labels and inputs using the "for" attribute, like so:
<label for="name">Please enter name</label>
<input type="text" id="name" name="name"/>
With this relationship in place the input field gains focus when you either click on the label or on the input itself to gain focus on the input.
In ionic you use ion-label and ion-input instead of the default HTML form elements, and these seem to not share this capability.
I am specifically interested in using an icon as the aforementioned label. I tried the following without any success:
<ion-item>
<ion-label for="searchText">
<ion-icon name="search"></ion-icon> <!--name here refers to the icon displayed-->
</ion-label>
<ion-input id="searchText" name="searchText" type="text" placeholder="Search" ></ion-input>
</ion-item>
Is there something similar that one can use, or do I need to use JavaScript to achieve this?
Any advice would be greatly appropriated
So since I've been asked for a solution by someone else, let me post the workaround that I used:
I never managed to find a way to automatically add this kind of functionality like in a normal form, I did manage to trigger a click event on the icon that then caller a JavaScript function to give focus to my input field. It looks something like this:
HTML:
<ion-item color="light" class="white-iput" lines="none" (click)="focusSearch()">
<button (click)="focusSearch()" class="icon-button">
<ion-icon name="search" color="primary" for="searchText"></ion-icon>
</button>
<ion-input #input id="searchText" type="text" placeholder="Search" ></ion-input>
</ion-item>
JS (in my Type Sctipr file):
#ViewChild('input') searchInput: { setFocus: () => void; } ;
...
focusSearch() {
this.searchInput.setFocus();
}
Note that I call the "focusSearch()" function if you click anywhere in the "ion-item" wrapped around the icon and the text box, as I use CSS to have the whole thing display as a single textbox.
Hope this helps!

Auto Keyboard in Input with Ionic

I need a routine on Ionic that calls the cellphone's Keyboard to an ion-input when entering the page.
An example of a page would be:
<ion-content padding>
<form>
<ion-row>
<ion-col>
<ion-input #user name="user" type="text" placeholder="Usuário"></ion-input>
</ion-col>
</ion-row>
</form>
</ion-content>
What I want is to use the Navigating Lifecycle from Ionic (I believe that in this case using the ionViewDidEnter) to bring the focus and the Keyboard in the field automatically, I have already tried some codes but unfortunately sometimes it works and sometimes not, thank you right away.
You can set focus in your textarea in the method ionViewDidEnter and show the keyboard by using keyboard plugin of ionic.
#ViewChild('user') input ;
ionicViewDidEnter(){
setTimeout(() => {
this.input.setFocus();
},150);
this.keyboard.show();
}
I have referred the following links. Please go through it for more information:
https://ionicframework.com/docs/native/keyboard/
https://forum.ionicframework.com/t/setting-focus-to-an-input-in-ionic/62789/4
Set focus on an input with Ionic 2

Emoji's not getting sent from text input in ionic

I am trying to send emoji's from input box once I click enter it's not getting sent in form of emojis it's getting converted into "??".
<ion-input autocomplete="true" spellcheck="true" class='input-cover' type="text" [(ngModel)]="userComment" placeholder="Post a Comment">
</ion-input>

Display html element from JSON object on ionic App

I have been trying to embed html element from JSON object, and It is currently displaying the html as raw code instead.
Can someone please help me ?
detail.ts
this.questionsData[i].question_type.title = "<ion-input type=\"text\" placeholder=\"Short answer\"></ion-input>";
detail.html
<ion-item *ngFor="let question of questionsData">
{{question.title}}
<br>
Text : {{question.question_type.title}}
<br>
<div [innerHTML]="question.question_type.title">
</div>
</ion-item>
Isn't it should be input box under the text : , anyone know why it's not rendered ?
Thanks
InnerHtml will only help to render pure html code on run time, you can't use ionic components to render dynamically using innerhtml. I think you need to use dynamic component loader feature in angular here. You can refer this link on use cases of this feature https://medium.com/#DenysVuika/dynamic-content-in-angular-2-3c85023d9c36
Your approach needs to change, do not include html tags in component block, instead add parameters as json data and set it at component. Then you can interpolate the tags in the template view.
Ex:
at the component:
this.inputDataArray = [{"title":"What cartoon do you like to watch?", "name":"inp1","placeholder":"short answer"},{"title":"What movie do you like to watch?", "name":"inp2","placeholder":"short answer"}];
at the view:
<ion-item *ngFor="let question of inputDataArray">
{{question.title}}
<br>
Text : <input name={{question.name}} placeholder={{question.placeholder}} />
<br>
</ion-item>
Its just a reference, Hope it helps
This worked for me.
<div [innerHTML]="data.text"></div>