Giter Club home page Giter Club logo

Comments (1)

JadedEric avatar JadedEric commented on June 10, 2024 2

@barigo the reason it's not working, is that the selected value might not have been loaded as part of the limit and as such, will not be picket up by.

i got around this by injecting a static mat-option at the top of the list to appear as the selected option, and the rest of the infinite scroll following that. i don't have an example at hand at the moment, but it is pretty simple to implement, something like this:

public hasDefault = false;

// somewhere where you get the default value, set the hasDefault flag to true.
this.hasDefault = this.data.item; // as an example, this.data.item contains the item I'm passing to a modal

then in the HTML you can do something like this:

<mat-option *ngIf="hasDefault" [value]="defaultItem.id">{{ defaultItem.caption }}</mat-option>

seeing that the option is now visible to the engine, it'll select that as the default until the value is changed

note, this is just a rough example and can be updated to fit your scenario. hope this helps.

from ng-mat-select-infinite-scroll.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.