Arquivo da tag: Ionic 2

Setting Focus to an Input in Ionic2

SOLVED :

[code type=typescript]
import {Component, Input, ViewChild} from ‘@angular/core’;
import {NavController} from ‘ionic-angular’;

@Component({
templateUrl: ‘build/pages/home/home.html’
})
export class HomePage {
@ViewChild(‘input’) myInput ;

constructor(private navCtrl: NavController) { }

ionViewLoaded() {

setTimeout(() => {
this.myInput.setFocus();
},150);

}
}

1) import “Input”, “ViewChild” and “NavController”

import {Component, Input, ViewChild} from '@angular/core';
import {NavController} from 'ionic-angular';

2) Create a reference to your input in your template :

<ion-input #input>

@ViewChild('input') myInput ;

3) Trigger the focus
[code type=typescript]
ionViewLoaded() {

setTimeout(() => {
this.myInput.setFocus();
},150);

}

4) Show the keyboard

add this line to your config.xml :

[code type=xml]

Ionic 2 Framework : Scroll To Bottom

[code type=javascript]
import { Component, ViewChild } from ‘@angular/core’;
import { Content } from ‘ionic-angular’;

export class ScrollToBottom {

@ViewChild(Content) content: Content;

constructor(){}

ionViewDidLoad()
{
setTimeout(() => {
this.content.scrollToBottom(300);
}, 1000);
}
}

https://stackoverflow.com/questions/37415085/ionic-2-angular-2-auto-scroll-to-bottom-of-list-page-chat

Ionic Framework : Scroll To Bottom

Como criptografar em MD5 com TypeScript?

https://www.npmjs.com/package/ts-md5

1. Passo é importar:
[code type=javascript]import {Md5} from ‘ts-md5/dist/md5’;

2. Exemplos:
[code type=javascript]Md5.hashStr(‘blah blah blah’) => hex:string
Md5.hashStr(‘blah blah blah’, true) => raw:Int32Array(4)
Md5.hashAsciiStr(‘blah blah blah’) => hex:string
Md5.hashAsciiStr(‘blah blah blah’, true) => raw:Int32Array(4)

Ionic 2 – Eventos nativos do NavController

[code type=javascript]
import { Component } from ‘@angular/core’;

@Component({
template: ‘Hello World’
})
class HelloWorld {
ionViewDidLoad() {
console.log(“I’m alive!”);
}
ionViewWillLeave() {
console.log(“Looks like I’m about to leave :(“);
}
}

Eventos:

  • ionViewDidLoad
  • ionViewWillEnter
  • ionViewDidEnter
  • ionViewWillLeave
  • ionViewDidLeave
  • ionViewWillUnload
  • ionViewCanEnter
  • ionViewCanLeave

http://ionicframework.com/docs/v2/api/navigation/NavController/#lifecycle-events