title: How to close ng-bootstrap modal after login?
body: <p><strong>This is my button to open login modal.</strong></p>
  
  <pre><code>&lt;form class="form-inline"&gt;
    &lt;button  class="btn btn-outline-success" type="submit" (click)="openLoginDialog(content)"&gt;Login&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>This is my component.ts</strong></p>
  
  <pre><code>modalReference = null;
   constructor(private modalService: NgbModal) { }
   openLoginDialog(content) {
  this.modalReference= this.modalService.open(content, { centered: true });
  
  
   }}
  </code></pre>
  
  <p><strong>login.component.ts</strong>
  *this is my login component where i have login function for template,i hve to close my temmplate after click on login button.My login functionallty is working fine. *</p>
  
  <pre><code>export class LoginComponent implements OnInit {
  modalReference: any; 
  constructor(private modalService: NgbModal) {}
  onSubmitLogin(){   
  this.dataservice.searchUser(this.user.email,this.user.password)
  .subscribe(
     results =&gt;
    { 
      localStorage.clear();
      localStorage.setItem('userpassword',JSON.stringify(this.user.password));
      localStorage.setItem('useremail',JSON.stringify(this.user.email));
      if(results.length == 1)
      {
        this.userlist = results;
       let id =results[0].id;
       this.dataservice.changeUser(this.userlist[0].firstName);
       this.modalReference.close();
      // this.modalService.open().close(results);
      }
  
      else{          
          alert ("Username Not found");
        }
    });
  }}
  </code></pre>
  
  <p><strong>Error</strong></p>
  
  <pre><code>ERROR TypeError: Cannot read property 'close' of undefined
  at SafeSubscriber._next (login.component.ts:78)
  at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.__tryOrUnsub (Subscriber.js:195)
  at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.next (Subscriber.js:133)
  at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._next (Subscriber.js:77)
  at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54)
  at MapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/map.js.MapSubscriber._next (map.js:41)
  at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54)
  at FilterSubscriber.push../node_modules/rxjs/_esm5/internal/operators/filter.js.FilterSubscriber._next (filter.js:38)
  at FilterSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54)
  at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber.notifyNext (mergeMap.js:79)
  at InnerSubscriber.push../node_modules/rxjs/_esm5/internal/InnerSubscriber.js.InnerSubscriber._next (InnerSubscriber.js:15)
  at InnerSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54)
  at XMLHttpRequest.onLoad (http.js:1543)
  at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
  at Object.onInvokeTask (core.js:3662)
  at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:420)
  at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:188)
  at ZoneTask.push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (zone.js:496)
  at invokeTask (zone.js:1540)
  at XMLHttpRequest.globalZoneAwareCallback (zone.js:1566)
  </code></pre>