make the div always show show in desktop screens and show in mobile screens only when…
- User
make the div always show show in desktop screens and show in mobile screens only when click on button angular
- Assistant
To achieve this functionality in Angular, you can use conditional rendering by binding the
ngIfdirective to a flag that is toggled when the button is clicked. Additionally, you can use CSS media queries to ensure the div is always shown on desktop screens.Here is an example implementation:
- In your component.ts file, declare a flag to control the visibility of the div:
typescript - User
i want one div not dublicate the div
- Assistant
If you want to have only one div that shows in mobile screens when the button is clicked, you can adjust the implementation as follows:
- In your component.ts file, declare a flag to track the button click and control the visibility of the mobile div:
typescriptimport { Component } from '@angular/core'; @Component({ selector: 'app-my-component', templateUrl: './my-component.component.html', styleUrls: ['./my-component.component.css'] }) export class MyComponent { isMobileVisible = false; toggleMobileVisibility() { this.isMobileVisible = !this.isMobileVisible; } }