如何在angular js中查找对象是否为formcontroller类型

How to find whether an object is of type formcontroller in angular js

我有一个嵌套表单。我想递归地验证它。在验证时,我需要检查对象是否属于 Formcontroller 类型。在尝试实例或类型时,我将其作为对象而不是表单控制器获取。请帮助找到这个。

如果你想知道一个对象是否属于某种类型,我相信你可以这样问:

  person = {
     id: 1,
     name: 'John',
     age: 46,
     active: true
  };

  house = {
     color: 'blue with white patterns',
     years: 20,
     isInGoodCondition: true
  };

  const myArray = [person, house];

  myArray.forEach((element) => {
     if (element?.name) console.log('It is a person object');
     if (element?.isInGoodCondition) console.log('It is a house object');
  });
  

object?.property 安全地询问 property 是否存在于您的对象中。