While the best way of reusing your code is creating a component, it's also possible to do it in a template.
To do this you can use ng-template
along with *ngTemplateOutlet
directive.
<p>
<ng-container *ngTemplateOutlet="fancyGreeting"></ng-container>
</p>
<button>
<ng-container *ngTemplateOutlet="fancyGreeting"></ng-container>
</button>
<ng-template #fancyGreeting>
Hello <b>{{name}}!</b>
</ng-template>