-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
  • 45,290
  • 60
  • 174
  • 267

1 Answers1

2

You could use the instanceof operator:

if (aa instanceof Control) {
  // do something
} else if (aa instanceof ControlGroup) {
  // do something
}
Thierry Templier
  • 198,364
  • 44
  • 396
  • 360