1

For example I have this component with a simple template:

  <div>
    <h2>Hello!!!</h2>
  </div>

and I want to add this new template tag:

  <div>
    <h2>Hello!!!</h2>
    <div class = "new-tag">
      </div>
  </div>

How can I do this? Thanks.

4
  • 1
    you just did it Commented Jan 4, 2017 at 18:00
  • I forgot, I want do this by something event, click for example Commented Jan 4, 2017 at 18:22
  • As I understand, you want to import another component in anothr component by css selector?? Commented Jan 4, 2017 at 19:30
  • @KirillAchramionok I updated my answer. It was poorly formatted and didn't show the code. Sorry for that. Commented Jan 3, 2018 at 12:50

1 Answer 1

1

Use a structural directive like *ngIf

  <div>
    <h2>Hello!!!</h2>
    <div *ngIf="showNew" class = "new-tag"></div>
    <button (click)="showNew = true">click me</button>
  </div>
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.