问问题
1010 次
1 回答
0
事情是$scope.inventory.condition
必须是$scope.conditions
数组元素,并且两个对象只有当它们是同一个对象时才相等。所以你不能只设置$scope.inventory.condition = {"name":"Used","id":102};
: event 虽然{"name":"Used","id":102}
看起来像数组的第二个值,但实际上它们并不相等,所以 Angular 不会将它设置为默认值。
您需要像这样设置模型值:
$scope.conditions = [
{"name":"New","id":101},
{"name":"Used","id":102},
{"name":"Like new","id":103},
{"name":"Not Working","id":104}
];
$scope.inventory.condition = $scope.conditions[1];
于 2015-03-25T21:31:22.847 回答