I am using Angular 5 with Boostrap 4. It works for me in this way.
$(document).on('click', '.navbar-nav>li>a, .navbar-brand, .dropdown-menu>a', function (e) {_x000D_
if ( $(e.target).is('a') && $(e.target).attr('class') != 'nav-link dropdown-toggle' ) {_x000D_
$('.navbar-collapse').collapse('hide');_x000D_
}_x000D_
});_x000D_
}
_x000D_
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">_x000D_
<a class="navbar-brand" [routerLink]="['/home']">FbShareTool</a>_x000D_
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarColor01" aria-controls="navbarColor01" aria-expanded="false" aria-label="Toggle navigation" style="">_x000D_
<span class="navbar-toggler-icon"></span>_x000D_
</button>_x000D_
_x000D_
<div class="collapse navbar-collapse" id="navbarColor01">_x000D_
<ul class="navbar-nav mr-auto">_x000D_
<li class="nav-item active" *ngIf="_myAuthService.isAuthenticated()">_x000D_
<a class="nav-link" [routerLink]="['/dashboard']">Dashboard <span class="sr-only">(current)</span></a>_x000D_
</li>_x000D_
<li class="nav-item dropdown" *ngIf="_myAuthService.isAuthenticated()">_x000D_
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">_x000D_
Manage_x000D_
</a>_x000D_
<div class="dropdown-menu" aria-labelledby="navbarDropdown">_x000D_
<a class="dropdown-item" [routerLink]="['/fbgroup']">Facebook Group</a>_x000D_
<div class="dropdown-divider"></div>_x000D_
<a class="dropdown-item" href="#">Fetch Data</a>_x000D_
</div>_x000D_
</li>_x000D_
</ul>_x000D_
_x000D_
<ul class="navbar-nav navbar-right navbar-right-link">_x000D_
<li class="nav-item" *ngIf="!_myAuthService.isAuthenticated()" >_x000D_
<a class="nav-link" (click)="logIn()">Login</a>_x000D_
</li>_x000D_
<li class="nav-item" *ngIf="_myAuthService.isAuthenticated()">_x000D_
<a class="nav-link">{{ _myAuthService.userDetails.displayName }}</a>_x000D_
</li>_x000D_
<li class="nav-item" *ngIf="_myAuthService.isAuthenticated() && _myAuthService.userDetails.photoURL">_x000D_
<a>_x000D_
<img [src]="_myAuthService.userDetails.photoURL" alt="profile-photo" class="img-fluid rounded" width="40px;">_x000D_
</a>_x000D_
</li>_x000D_
<li class="nav-item" *ngIf="_myAuthService.isAuthenticated()">_x000D_
<a class="nav-link" (click)="logOut()">Logout</a>_x000D_
</li>_x000D_
</ul>_x000D_
_x000D_
</div>_x000D_
</nav>
_x000D_