Hi Team
I need some help when i run this code on coderbyte online IDE its giving me errors. The main objective is for me to toggle button on when its clicked and off when off. I tried to use this code found online as a test but in online IDE it does work.
// toggle button on and off using angular component ts and class
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
template: `
Angular Toggle Button
The state is {{checked ? 'ON' : 'OFF'}}.
`,
styles: [ `
h1 {
color: #DB5B33;
font-weight: 300;
text-align: center;
}
toggle-button {
margin: 0 auto;
}
`]
})
export class AppComponent {
checked: boolean;
}
Tuhin PaulPosted Mar 1, 2023, 3:30 AM
Hi Gcobani,
I think you are using a custom component called "toggle-button" that is not defined in the code snippet you have provided. This could be the reason for the errors you are facing when running it on the online IDE.
You can try to define the "toggle-button" component in your code or use a pre-defined Angular Material button and implement the toggle functionality yourself.