Click here to Skip to main content
16,017,857 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi Team

I need some help i have created a template to toggle between on and off but now must find a way to create a component ts so when switch toggle button is on it should and vice versa in Angular

What I have tried:

// @ts-ignore
import { Component } from '@angular/core';

@Component({
  selector: 'app-toggle-button',
  template: `<ng-container *ngIf="show; then showTpl; else hideTpl">
  </ng-container> 
  <button (click) = "show = !=show">Toggle View</button>
  <ng-tample #showTpl>
    True
  </ng-template>

  <ng-template #hideTpl>
      False
  </ng-template>                                                                                                                                   
  `,
  styles: [``]
})

export class MainAppComponent {
  // code goes here
  
  }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900