i\'m using ng-bootstrap and i want to get the value of dropdown when selected .
-
This runs without any javascript backend code. Solution is build upon angular template variables.
Until no item is selected a place holder text "Select Environment" is displayed.
<div ngbDropdown class="d-inline-block">
<button class="btn btn-outline-primary" id="dropdown"
ngbDropdownToggle>{{ selectedValue.value || "Select Environment" }}</button>
<div ngbDropdownMenu aria-labelledby="dropdown" #selectedValue>
<div *ngFor="let env of environments;" >
<button ngbDropdownItem id="option" on-click="selectedValue.value=env">{{env}}
</button>
</div>
</div>
</div>
讨论(0)
-
You need to add a click event:
<button class="dropdown-item" (click)="changeAction(obj)">
In the component:
changeAction(obj) {
//your logic here
}
讨论(0)