Ionic 2 Component Inline Html


#1

Hi,

A lot of Ionic 2 and Angular 2 examples and tutorials use html template in Component javascript file by using “template” instead of “templateUrl”. Is this the best practice in Angular 2 or is it just for the sake of tutorial simplicity?

Example from Angular.io website:
Angular 2 Tutorial Part-1


#2

For me it depends on how much HTML the component is going to get. If its like two lines I find using templateUrl is a bit much. But if it is a more complex html component with more lines I find that creating a separate view and thus using `templateUrl is easier to maintain.

Futher in that tutorial they describe the templateUrl part => https://angular.io/docs/ts/latest/tutorial/toh-pt5.html.

I think in tutorials its most used for tutorial simplicity :slight_smile: