How to configure NgbDropdown to display the selected item from the dropdown

后端 未结 2 459
清酒与你
清酒与你 2021-01-04 03:06

In ng-bootstrap NgbDropdown, how would you display the text of the selected button so that what ever item the user selects replaces the default text initially shown?

2条回答
  •  醉酒成梦
    2021-01-04 03:35

    Demonstrated in this plunkr.

    Example Component:

    import {Component} from '@angular/core';
    
    @Component({
      selector: 'dropdown-demo-sortby',
      template: `
        
    ` }) export class DropdownDemoSortby { sortOrders: string[] = ["Year", "Title", "Author"]; selectedSortOrder: string = "Sort by..."; ChangeSortOrder(newSortOrder: string) { this.selectedSortOrder = newSortOrder; } }

提交回复
热议问题