Angular4: Component.name doesn't work on production

后端 未结 4 1682
有刺的猬
有刺的猬 2021-01-03 10:42

So I\'ve been facing this weird issue but I\'m not sure if it\'s a bug or it\'s me missing something here.
So I have a component called TestComponent and in

4条回答
  •  走了就别回头了
    2021-01-03 11:20

    I just answered a related question here

    To workaround mangling class names, you can create a function and check if it is equal to the class you want to test. In this case for TestComponent, you could use this:

    getType(o: any): string {
          if (o === TestComponent)
              return 'TestComponent';
    }
    

    And calling it will print the Component name:

    console.log(getType(TestComponent)); // will print 'TestComponent'
    

提交回复
热议问题