0

How to render dynamic html inside {{ name }}?

let fname="faisal";
data1="<h1>{{fname}}</h1>";

let lname="Khan";
data2="<h1>{{lname}}</h1>";

how to get output like this : {{ data1 }} {{ data2 }} = faisal khan

2
  • Why don't you put the h1 into the template, then do <h1>{{ fname }} {{ lname }}</h1>? That way you'll only have a single element, too. Commented Jun 30, 2019 at 13:40
  • 1
    angular.io/start Commented Jun 30, 2019 at 13:40

1 Answer 1

0

You can display your full name without data1, data2

If you have data1, data2 you need style for h1 display: inline-block

<h1>{{fname}} {{lname}}</h1>

Demo https://stackblitz.com/edit/angular-pcw58e

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.