Answer the question
In order to leave comments, you need to log in
How to solve problem with default values in select angular?
Hello. Started learning angular and ran into a problem.
I have 2 objects in scope:
1)
tasks:
12:
id: 12
user_id: 1
и т.д.
2)
users:
1:
id: 1
username: sergey
<select class="form-control"
data-ng-model="tasks[task.id].user_id"
data-ng-change="setWorker(task.id)"
>
<option data-ng-repeat="user in users" data-ng-value="user.id" data-ng-selected="{[{user.id == task.user_id}]}">{[{user.username}]}</option>
</select>
<option value="? number:4 ?"></option>
$scope.users = data.toJSON();
$scope.$watch('tasks', function () {
$scope.test();
})
Answer the question
In order to leave comments, you need to log in
Apparently it should be like this ?
2. because of that. that users is not an array but an object.
3. for arrays you need to use $watchCollection
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question