Angularjs 尽管选择了选项,但必需的角度设置错误

Angularjs 尽管选择了选项,但必需的角度设置错误,angularjs,Angularjs,我有这段代码,其中有$index,因为select在ng repeater中,我有多个动态生成的 <select name="udaljenosti_{{$index}}" ng-model="attribute.Choices.Id" class="form-control" required> <option value="" >--Choose--</option> <

我有这段代码,其中有$index,因为select在ng repeater中,我有多个动态生成的

<select name="udaljenosti_{{$index}}" ng-model="attribute.Choices.Id" class="form-control" required>
                    <option value=""  >--Choose--</option>
                    <option ng-repeat="choice in attribute.Choices" value="{{choice.Id}}" ng-selected="choice.IsSelected==true">
                        {{choice.Name}} </option>
                </select>
正如你所看到的,有一个选择的属性。如果所有选项的IsSelected==false,则在提交时,由于select上的required属性,我得到一个错误,即某些选项是必需的,而当我在select上选择某些选项并点击submit时,则没有错误。很好,到目前为止。但是,当从数据库中预填充某个选项时,会出现一些奇怪的行为。一切似乎都很好,但当我点击submit时,他说选择字段有错误。它说需要选择,但是已经选择了一些选项!!
编辑:似乎名称和ng模型应该更多。如何做到这一点,因为如果我将uudaljenosti{{{$index}}放在ng模型中,会出现错误。

使用ng选项而不是ng重复。在这种情况下,required不起作用。看到这个了吗:我看到的不是这个。在你的两个例子中,你都在使用ng-repeat,在所有答案中,你都在使用ng-options。请再次阅读。如果我使用ng选项,则预编程不起作用。您接受的答案是什么,即您的错误是使用ng model=attribute.Choices.Name,而不是ng model=attribute.Choices.Id与ng选项vs ng repeat有什么关系?