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

dynamicly change the select options does not work in the right way #17028

Closed
yupengfei opened this issue Jan 10, 2019 · 2 comments
Closed

dynamicly change the select options does not work in the right way #17028

yupengfei opened this issue Jan 10, 2019 · 2 comments
Labels

Comments

@yupengfei
Copy link

Bug Report

Ionic version:

[x] 4.x

Current behavior:

  updateOptions() {
    
    this.testNodes =  [
    {
      name: "gg",
      value: "GG",
      selected: true,
    },
    ]
  }

After updateOptions runs, I hope the select overlay shows only "GG".
Expected behavior:

The select overlay shows both "GG" and "BB".

Steps to reproduce:

Related code:
A sample application via GitHub

import { Component, State } from '@stencil/core';

class Node {
  name: string;
  value: string;
  selected: boolean = false;
}
@Component({
  tag: 'app-home',
  styleUrl: 'app-home.css'
})
export class AppHome {


  @State() testNodes: Node[] = [];


  asyncGet(): Promise<any> {

    let testNodes = [{
      name: "aa",
      value: "AA",
      selected: false,
    }, {
      name: "bb",
      value: "BB",
      selected: true,
    },
    ]
    let promise = new Promise((resolve, _) => {
      setTimeout(() => resolve({  "testNodes": testNodes }), 1000)

    })
    return promise;
  }
  componentDidLoad() {
    this.asyncGet().then(result => {
      console.log(result.defaultNode);

      this.testNodes = result.testNodes;
    })
  }

  updateOptions() {
    
    this.testNodes =  [
    {
      name: "gg",
      value: "GG",
      selected: true,
    },
    ]
  }
  render() {
    return (
      <div>
        <ion-button onClick={()=>this.updateOptions()}>ddd</ion-button>
        

        <ion-select >
          {
            this.testNodes.map((node) =>
              <ion-select-option value={node} selected={node.selected} >{node.value}</ion-select-option>
            )
          }
        </ion-select>
      </div>

    );
  }
}

Other information:

Ionic info:

insert the output from ionic info here
@ionitron-bot ionitron-bot bot added the triage label Jan 10, 2019
@manucorporat
Copy link
Contributor

manucorporat commented Jan 11, 2019

Thanks for the issue, but it's a duplicate of #16453

@ionitron-bot
Copy link

ionitron-bot bot commented Feb 10, 2019

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Feb 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants