I want to change value of a Boolean variable in Angular when a user clicks out of a div
box. For this I think I should bind the variable with (mouseleave)
and (click)
i.e if both the events occur than only value changes. Here Boolean variable is isOpen
in .component.html
my code is like this.
<div id="box1">
<!--div content-->
</div>
In div
box1
I want to close it if we click out of it.How can I do this?
Below is the TypeScript code for it.
import {
Component,
OnInit
} from '@angular/core';
@Component({
selector: 'service-box',
templateUrl: './service-box.component.html',
styleUrls: ['./service-box.component.scss']
})
export class ServiceBoxComponent implements OnInit {
public isOpen = false;
constructor() { }
ngOnInit() {
}
}