title: How to perform the Onclick event in primeNG menu bar
body: <p>How to perform the On-click event using the PrimeNG.</p>
  
  <p>When we click on the New menu bar to get the UserFormComponent.html page to Add new user.Using PrimeNG how can we perform this.</p>
  
  <p>My Code is available at: <a href="https://stackblitz.com/edit/angular-rlf3nz" rel="nofollow noreferrer">https://stackblitz.com/edit/angular-rlf3nz</a>
  appcomponent.html</p>
  
  <pre><code>&lt;p-menubar [model]="items"&gt;
  </code></pre>
  
  <p>appcomponent.ts</p>
  
  <pre><code>export class AppComponent {
    private user = new User();  //Newly added  
    constructor(private _userService:UserService) { }  //Newly added
  
    title = 'clientApp';
    private items: MenuItem[];
  
    ngOnInit() {
      this.items = [
      {
        label: 'Quotes',
        items: [
          { label: 'New ', icon: 'fa fa-refresh',  command: () =&gt; this.addNewUser()},
          { label: 'Show All', icon: 'fa fa-repeat', url: '#' }             
        ]
      }
  
     addNewUser(){
        this.user=this._userService.getter();
     } 
  </code></pre>
  
  <p>}</p>
  
  <p>this is my UserFormComponent.html</p>
  
  <pre><code>&lt;div class="container"&gt;
    &lt;form (ngSubmit)="processForm()"&gt;      
        &lt;div class="form group"&gt;
          &lt;label for="username"&gt;User Name&lt;/label&gt;
          &lt;input type="text" name="username" class="form-control" [(ngModel)]="user.username"&gt;
        &lt;/div&gt;
        &lt;div class="form group"&gt;
            &lt;label for="type"&gt;Type&lt;/label&gt;
            &lt;input type="text" name="type" class="form-control" [(ngModel)]="user.type"&gt;
        &lt;/div&gt;
  
        &lt;div class="form group"&gt;
          &lt;label for="modelname"&gt;Model Name&lt;/label&gt;
          &lt;input type="text" name="modelname" class="form-control" [(ngModel)]="user.modelname"&gt;
        &lt;/div&gt; 
              &lt;input type="submit" value="save" class="btn btn-success"&gt;
    &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>this is my UserFormComponent.ts</p>
  
  <pre><code>export class UserFormComponent implements OnInit {
    private user:User;
    constructor(private _userService:UserService,private _router:Router) {
  
     }
  
    ngOnInit() {
    this.user=this._userService.getter();
    }
  
    processForm(){
      if(this.user.id==undefined){
         this._userService.createUser(this.user).subscribe((user)=&gt;{
           console.log(user);
           this._router.navigate(['/']);
         },(error)=&gt;{
           console.log(error);
         });
      }else{
         this._userService.updateUser(this.user).subscribe((user)=&gt;{
           console.log(user);
           this._router.navigate(['/']);
         },(error)=&gt;{
           console.log(error);
         });
      }
    }
  </code></pre>