Differences of using Component template vs templateUrl

前端 未结 6 1234
一整个雨季
一整个雨季 2020-12-14 08:22

Angular 2 allows to write multi-line templates by using ` characters to enquote them. It is also possible to put multi-line template into .html file and referen

6条回答
  •  旧时难觅i
    2020-12-14 08:53

    The drawbacks are that the IDE tooling isn't as strong as mentioned above, and putting large chunks of html into your components makes them harder to read.

    Also, if you are following the angular2 style guide, it recommends that you do extract templates into a separate file when longer than 3 lines.

    From the angular2 style guide :

    Do extract templates and styles into a separate file, when more than 3 lines.

    Why? Syntax hints for inline templates in (.js and .ts) code files are not supported by some editors.

    Why? A component file's logic is easier to read when not mixed with inline template and styles.

    Source

提交回复
热议问题