Tuesday 12 March 2019

null check in angular2

import { Injectable } from '@angular/core';
@Injectable()
export class Common {
    constructor() { }
    IsEmpty(str: string): boolean {
        return str === undefined || str === null || str === '';
    }
}

// Implementation:
var val="abc";
if (this.common.IsEmpty(val)) { return; }

No comments:

Post a Comment