Hello,
I begin with Ionic and ask for advice on this.
*.ts:
import { Component } from ‘@angular/core’;
import { AlertController } from ‘ionic-angular’;
import { Storage } from ‘@ionic/storage’;
@Component({
selector: 'page-hello-ionic',
templateUrl: 'hello-ionic.html'
})
export class HelloIonicPage {
constructor(public alertCtrl: AlertController, public storage: Storage ) {
storage.set('name', 'Martin');
// Or to get a key/value pair
storage.get('name').then((val) => {
console.log('Your name is ' + val);
})
}
showAlert() {
let alert = this.alertCtrl.create({
title: 'New Friend!',
subTitle: 'Your friend, Obi wan Kenobi, just accepted your friend request!',
buttons: ['OK']
});
alert.present();
}
} indent preformatted text by 4 spaces
*.html:
Hello Ionic
<ion-content padding class="action-sheets-basic-page">
<button ion-button block outline (click)="showAlert()">
Show Action Sheet
</button>
<div class="input-controls">
<h4>"Two way bindings"</h4>
<input [(ngModel)]="name" />
<div>Current Value: {{name}}</div>
</div>
<p [style.background]="'lime'">I am green with {{storage.val}}!</p>
</ion-content>
I need a variable name to write:
- Alert window
- on html page instead of {{}} storage.valPreformatted text