1

I'm very confused. I hope you can help me.

This is my factory

productsFactory.getAllDiciplines = function(){
  return $resource('/api/disciplines/');
}

It returns an array.

This is my controller:

$scope.diciplines = ProductsFactory.getAllDiciplines().query();

This is my view:

<select ng-model="diciplines" ng-options="d.dp_title for d in diciplines"></select><br>

This works. However, when I choose an item in my selectbox. It get's empty. All items disappear. I know this has something do to with that $resource uses asyncronous calls.

How do I fix this?

1
  • you are overriding property in ng-model Commented Sep 19, 2013 at 8:36

1 Answer 1

1

Your selected item is the whole list !

<select ng-model="diciplines" ng-options="d.dp_title for d in diciplines"></select><br>

create another property some thing SelectedDicipline and bind it

$scope.SelectedDicipline  = {};
<select ng-model="SelectedDicipline" ng-options="d.dp_title for d in diciplines"></select><br>
Sign up to request clarification or add additional context in comments.

1 Comment

Ha, thx! How embarrassing. You don't happen to know how to set the default value? As it is now it's empty.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.