1

 @Component({
     selector: 'app-data',
     template: <div><input type="button" (click)="getData();" value="GET DATA"/>    </div> <div id="child">{{data}}</div>
})

2

1 Answer 1

2

You can use the Angular 2 innerHTML binding:

<div [innerHTML]="yourHtmlContentVariable"></div>
Sign up to request clarification or add additional context in comments.

3 Comments

Hi Sjors, i have to try with http request and render html response that content js or css so how can be do that on button click
If I understand your question correct: you can create a variable for the innerHTML binding, which will be an empty string on init. When your http request has finished, assign the response to that variable
Alright! Can you mark the answer as the solution to your problem?

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.