简体   繁体   中英

How to highlight some options of ngb-typeahead based on a condition?

https://ng-bootstrap.github.io/#/components/typeahead/examples#focus

In this demo, I have to make the dropdown options with value which starts with 'M' and 'N' to be permanently highlighted with green and rest with yellow. How to achieve this?

Can be done my joining lots of different CSS concept together first go down to element by using ng:deep, then add regex to parameter of attribute which contains text.

::ng-deep .dropdown-menu .dropdown-item  ngb-highlight[ng-reflect-result^='M'] {
  background-color: pink;
}

I have edited a stackblitz example here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM