Closed SjurWarEagle closed 8 years ago
Hey @SjurWarEagle , I'm unable to reproduce this problem on my end. Here is my test setup:
dd.html
<StackLayout>
<StackLayout>
<DropDown #dd backroundColor="red" [hint]="ddHint" [items]="items" [selectedIndex]="selectedIndex" (selectedIndexChange)="onchange(dd.selectedIndex)"></DropDown>
<DropDown #dd1 backroundColor="blue" [hint]="ddHint1" [items]="items1" [selectedIndex]="selectedIndex1"></DropDown>
</StackLayout>
</StackLayout>
dd.component.ts
import {Component} from "@angular/core";
@Component({
selector: "my-app",
templateUrl: "dd.html",
styleUrls: ["app.css"]
})
export class DropDownComponent {
public selectedIndex;
public selectedIndex1;
public items: Array<string> = [];
public items1: Array<string> = [];
public ddHint = "Some hint";
public ddHint1 = "Some hint1";
constructor() {
for (var i = 0; i < 5; i++) {
this.items.push("data item " + i);
this.items1.push("data 2nd item " + i);
}
}
public onchange(selectedi){
console.log("selected index " + selectedi);
}
}
Can you provide more details. Also what version of {N} and Angular do you have in your package.json?
Hi, thanks for your reply. This is strange. I put your code in a new page in my app and it worked fine. Then I reactivated my commented out code for the hints in my app and it worked. The next day, it didn't work, both versions didn't.
I'm using nativescript 2.1.1 with android runtimeversion 2.1.1 and angular 2.0.0-rc.3. The page is navigated to by angular routing: { path: "ThePage", component: ThePage}, nothing special.
Currently I'm guessing this is some problem during the page-initilization something timing related.
could you try this code?
constructor() {
let that = this;
setTimeout(() => {
for (var i = 0; i < 5; i++) {
this.items.push("data item " + i);
this.items1.push("data 2nd item " + i);
}
that.ddHint = "Some hint";
that.ddHint1 = "Some hint1";
}, 1000);
}
Just for understanding, is there anything speaking against the check in _onHintPropertyChanged? You are checking the existance of "android" in _onItemsPropertyChanged before accessing it and with this check if works fine every time. I forked you project to verify this and it works like charm. I totally can understand the desire to reproduce the problem :) I'm very new to the nativescript world, so there will be something I don't see which speaks against the check. Performance?
Hey @SjurWarEagle , I was able to simulate and fix the problem. It was happening when navigating to a page, and in my first test, the default page container the drop down.
There are no perf issues, I just want to simulate the problem locally so I'm sure the fix will actually fix this. Thanks!
@PeterStaev the bugfixes are working fine, may thanks!
Hey,
currently the drop-down.android.js contains:
the check if this._android exists is missing:
would be great, if you could add it to https://github.com/PeterStaev/NativeScript-Drop-Down/blob/master/drop-down.android.ts#L120
Not having this check results in only the first hint being rendered and of there is more than one drop-down, the others don't get their hint. Also this ugly exception occurs:
My xml:
Thanks :)