1
私のアプリが初めて実行されたときに、たくさんのコマンドを実行しようとしています。私はいくつかのコードを見つけましたが、それらのどれも私のために働くようです。ここで私が今持っているものです。初めてアプリを実行しているときにイオンを使って何かを実行するには?
var applaunchCount = this.storage.get('launchCount');
console.log(applaunchCount);
if(applaunchCount){
this.hello="succesive";
}else{
storage.set('launchCount','1');
this.hello="first";
}
私はハローの値は常に「succesive」のまま私のAndroidデバイス上でそれを試してみました。 編集:あなたは、データがそれを使用する前に準備ができるまで待たなければならないので、 最初のページですhome.tsファイル
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { FormBuilder, Validators } from '@angular/forms';
import {cloths} from '../defaults.component';
import { Storage } from '@ionic/storage';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
hello : string;
clothes=cloths;
l : string ;
public loginForm = this.fb.group({
new: ["", ]
});
constructor(public navCtrl: NavController, public fb:FormBuilder, public storage:Storage) {
var applaunchCount = this.storage.get('launchCount');
var app : string;
console.log(applaunchCount);
if(applaunchCount){
//This is a second time launch, and count = applaunchCount
this.hello="succesive";
}else{
//Local storage is not set, hence first time launch. set the local storage item
storage.set('launchCount','1');
this.hello="first";
//Do the other stuff related to first time launch
}
}
buttonLogin(){
this.clothes.push(this.loginForm.get('new').value);
}
}
'applaunchCount'の値は何ですか – Duannx
app.component.tsのコンストラクタ内にコードを追加します – Gowtham
@Duannx logステートメントは何も表示しません。その空の –