Follow the codes. While hiding the menu, it does not re-open with the "click" function in nav-burger
menu.component:
section class="hero outer is-primary is-fullheight animated slideInLeft" [ngClass]="{'is-hidden' : !menu.opened}">
menu.service.ts:
@Injectable()
export class MenuService {
opened: boolean;
constructor() { }
open (){
this.opened = true;
}
}
header.component.ts:
@Component({
providers: [MenuService],
selector: 'app-header',
templateUrl: './header.component.html',
styleUrls: ['./header.component.sass']
})
export class HeaderComponent implements OnInit {
constructor(public menu:MenuService) {
header html:
<div class="navbar-burger burger" (click)="menu.open()">
<span></span>
<span></span>
<span></span>
</div>