-1
let aa = this._formBuilder.control("");
let bb = this._formBuilder.group({
    aa: aa
};

I want to do something like this:

if (typeof(aa) == "Control") {
    // do something
} else if (typeof(aa) == "ControlGroup") {
    // do something
}

But right now both typeof(aa) and typeof(bb) returns object.

console.log(typeof(aa));  // object
console.log(typeof(bb));  // object

How to know whether it is Control or ControlGroup? Thanks

Hongbo Miao
  • 38,184
  • 54
  • 150
  • 228

1 Answers1

2

You could use the instanceof operator:

if (aa instanceof Control) {
  // do something
} else if (aa instanceof ControlGroup) {
  // do something
}
Thierry Templier
  • 191,422
  • 38
  • 386
  • 349