App crash when nothing is filled in ion-input using keychain

Hello there,

I just tested the Keychain-plugin and it works fine, except when my ion-input is empty before the first click on save.
If I write something into the input field and click on save anything works, and if I empty the field after and click on save, I get the alert I want to have.

But like I said, if I press save after open the app, it crashes

my home.ts:

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Keychain} from "@ionic-native/keychain";

  selector: 'page-home',
  templateUrl: 'home.html'
export class HomePage {

  public name: string;
  public getName: string;

  constructor(public navCtrl: NavController, private keychain: Keychain) {


  saveWithKeychain() {
    if ( !== '') {
      this.keychain.set('login',, true);
    } else {
      alert('No Name');

  loadWithKeychain() {
    this.keychain.get('login', 'Touch it').then(data =>{
      this.getName = data;


and my home.html:

      Ionic Blank

<ion-content padding>
     <ion-input type="text" [(ngModel)]="name"></ion-input>

   <button ion-button (click)="saveWithKeychain()">Save your Name</button>
   <button ion-button (click)="loadWithKeychain()">Load the Name</button>

     <p>Get Name: {{getName}}</p>


Thank you in advance

figured it out myself…
just had to replace ‘’ in my if with null …