Closed wendt88 closed 6 years ago
Hey @wendt88 ,
For 1 - this is a really strange error. setEnabled
is a valid method for the spinner per the android docs.
For 2 - Make sure you are using the module as explained in the readme. Also you might have to initialize the items
property and probably use the angular async
pipe with it since you are retrieving the data with an API call.
For 2 - I initialize my items in ngOnInit
as a empty ValueList
and call on api request end multiple times the push method to write the items in it. I resolved it adding the ngDefaultControl
attribute found here
But now my itemIndex
get not changed on select (selectedIndexChanged
event gets called)
TextFields with [(ngModel)] works fine.
I use:
@angular: "~4.4.5"
nativescript-drop-down: "^3.2.0"
tns-core-modules: "~3.2.0"
How are you registering the module? You should not use ngDefaultControl
and the widget already implements its own value accessor.
I started with the NativeScript/sample-Groceries repository
and imported the DropDownModule
in the app.module.ts.
The drop is in my login component which is declared in the login.module.ts
I'm not sure what could be wrong. I would suggest to look at the demo-ng
project in this repo and see what you are doing differently in your project so you can isolate what the problem is.
Problem 2 solved:
I have to import the DropDownModule
in the submodule (in groceries sample is it the LoginModule
and GrocieruesModule
) instead of the AppModule
.
Now I created my own "SharedModule
", where I import the DropDownModule
(here you can also declare your own pipes, services, components etc. if somene is interested) and export everything of it.
Thank you for your help!
1)
ERROR Error: java.lang.Exception: Failed resolving method setEnabled on class android.widget.Spinner
-> items are a ValueList2)
ERROR Error: No value accessor for form control with unspecified name attribute
-> only if myValueList
is empty (I fetch the items for theValueList
via api call, so I get this error and no[text]
or[hint]
attributes in the whole page get evaluated until I fill myValueList
). Removing[(ngModel)]
solves the problem!I tried to set as
itemIndex
various initial values (null, undefined, 0, etc)