Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async options in select are not reflected #88

Closed
shindekaps opened this issue Mar 30, 2017 · 4 comments · Fixed by #91
Closed

Async options in select are not reflected #88

shindekaps opened this issue Mar 30, 2017 · 4 comments · Fixed by #91
Assignees
Labels

Comments

@shindekaps
Copy link

Ng for not working for select component

@shindekaps shindekaps changed the title NgFor Not working NgFor Not working for mz-select-container options Mar 30, 2017
@scote scote added the Bug label Mar 30, 2017
@jfcere jfcere self-assigned this Mar 30, 2017
@jfcere
Copy link
Contributor

jfcere commented Mar 30, 2017

Hi @shindekaps,

I am not really sure I understand the problem as I would need more information.

To use ngFor on options you can follow the example below ...

example.component.html

<mz-select-container>
  <select mz-select
    id="select-number"
    [label]="'Number'"
    [placeholder]="'Choose a number'"
    [(ngModel)]="optionValue">
    <option *ngFor="let option of ['one','two','three','four']" [selected]="option === optionValue">{{ option }}</option>
  </select>
</mz-select-container>

OptionValue => {{ optionValue }}

example.component.ts

public optionValue: string;

If it does not solve your issue please provide a sample of your code.

Thanks,

@shindekaps
Copy link
Author

shindekaps commented Mar 31, 2017

Hi,
*ngFor is working when data is hard coded. When the data is coming asynchronous then it not working. Also I got workaround when we use ngIf then it is working.
E.g.

<mz-select-container>
  <select mz-select
    id="select-number"
    [label]="'Number'"
    [placeholder]="'Choose a number'"
    [(ngModel)]="optionValue">
    <option *ngFor="let option of comapnyList" [selected]="option === optionValue">{{ option }}</option>
  </select>
</mz-select-container>

where companyList is coming from server.Above example is not working. But when we add *ngIf then it is working
E.g.

<mz-select-container *ngIf="comapnyList.length>0">
  <select mz-select
    id="select-number"
    [label]="'Number'"
    [placeholder]="'Choose a number'"
    [(ngModel)]="optionValue">
    <option *ngFor="let option of comapnyList" [selected]="option === optionValue">{{ option }}</option>
  </select>
</mz-select-container>

Thanks
Kapil Shinde

@charpeni
Copy link
Contributor

charpeni commented Apr 3, 2017

Thank you for the reporting, you're right there're bugs with async options.

We're on it.

@charpeni charpeni changed the title NgFor Not working for mz-select-container options Async options in select are not reflected Apr 3, 2017
@jfcere jfcere assigned charpeni and unassigned jfcere Apr 10, 2017
@charpeni
Copy link
Contributor

@shindekaps it should be fixed by #91 and it will be released to npm in the next days/weeks.

If there is anything else or if the issue is not properly fixed, feel free to ping us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants