我在单页中使用了两个下拉组件,但只有第一个在nativescript ios中显示数据而不是第二个

时间:2017-03-31 10:26:42

标签: ios nativescript

我在nativescript ios中使用了下拉组件,但只有一个组件加载的数据不是第二个

//this is my code where i have used dropdown

<StackLayout orientation="horizontal" width="100%" class="padding">
      <StackLayout orientation="horizontal" horizontalAlignment="left" width="50%">
        <GridLayout rows="auto, auto, *" columns="auto, *" class="newstack">
          <TextField [(ngModel)]="userRegister.langauge" class="noline"></TextField>
          <DropDown #Langauge hint="Langauge" class="Nopadding" backgroundcolor="transparent" [items]=ArrayLangauge [selectedIndex]="selectedIndex"
            (selectedIndexChange)="onchangeLanguage(Langauge.selectedIndex)" row="0" colSpan="1"></DropDown>
        </GridLayout>
      </StackLayout>


      <StackLayout orientation="horizontal" textWrap="true" horizontalAlignment="right" width="50%">
        <GridLayout rows="auto, auto, *" columns="auto, *" class="newstack" horizontalAlignment="center">
          <TextField [(ngModel)]="userRegister.state" class="noline"></TextField>
          <DropDown #State hint="State" class="Nopadding" backgroundcolor="transparent" [items]="ArrayState" [selectedIndex]="selectedIndex"
            (selectedIndexChange)="onchangeState(State.selectedIndex)" row="0" colSpan="1"></DropDown>
        </GridLayout>
      </StackLayout>
    </StackLayout>

2 个答案:

答案 0 :(得分:0)

乍一看,在第一个下拉控件(缺少引号)中传递项目时会出现语法错误。 这个unordered_map应该成为

[items]=ArrayLangauge

Here您可以找到基本项目,演示在一个页面上使用两个下拉列表

答案 1 :(得分:0)

这可能导致您的第二个下拉列表问题的是,您为[selectedIndex] =&#34; selectedIndex &#34下拉列表使用相同的变量名称;更改我加粗的字符串的名称。尝试这一点,除了你的代码是好的,我自己在一个页面中使用了5个下拉,适合我。