How to load conditionally templateUrl html file in Angular 5 component

前端 未结 2 1759
一个人的身影
一个人的身影 2021-02-09 00:31

There is one scenario in my project, Consider, I have one testDynamic component

@Component({
    templateUrl: \"./test-dynamic.html\", // Need to override this f         


        
2条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-09 01:16

    You can't add more than one HTML file.

    What you can do is, use *ngIf or *ngSwitchCase to show only parts of the template if that is your intention. Then you have only one template html file.

    Then html of your template will be something like this:

    View 01
    View 02

提交回复
热议问题