gpt4 book ai didi

javascript - '_item_' 中的 Angular ngRepeat 错误 '_item_ in _collection_' 应该是标识符 '(_key_, _value_)' 表达式

转载 作者:行者123 更新时间:2023-11-30 15:31:06 26 4
gpt4 key购买 nike

我正在尝试下面的代码

element.append('<label value="{{feat.Name}}">{{feat.Name}}</label><md-select ng-model="feat.Value"> <md-option><em>None</em></md-option> <md-option ng-repeat="x for x in feat.AllowedValues.split(\',\')"  ng-value="x.value" ng-disabled="$index === 1"/>{{x.value}}</md-option></md-select>');

低于错误

Error: [ngRepeat:iidexp] 'item' in 'item in collection' should be an identifier or '(key, value)' expression, but got 'x for x'.

当我尝试使用

element.append('<label value="{{feat.Name}}">{{feat.Name}}</label><select ng-model="feat.Value" ng-options="x for x in feat.AllowedValues.split(\',\')"></select>');

成功了,你能告诉我第一个代码有什么问题吗?

最佳答案

你犯了一个小错误element.append('<label value="{{feat.Name}}">{{feat.Name}}</label><md-select ng-model="feat.Value"> <md-option><em>None</em></md-option> <md-option ng-repeat="x for x in feat.AllowedValues.split(\',\')" ng-value="x.value" ng-disabled="$index === 1" /> (此处关闭) {{x.value}}</md-option></md-select>');

我们可以像这样关闭任何元素

<element />

<element></element >

更新

删除 x for来自 ng-repeat="x for x in feat.AllowedValues.split(\',\')" .我不知道,但它不适用于 <md-option>

element.append('<label value="{{feat.Name}}">{{feat.Name}}</label><md-select ng-model="feat.Value"> <md-option><em>None</em></md-option> <md-option ng-repeat="allowedValue in feat.AllowedValues.split(\',\')"  ng-value="allowedValue" ng-disabled="$index === -1">{{allowedValue}}</md-option></md-select>');

关于javascript - '_item_' 中的 Angular ngRepeat 错误 '_item_ in _collection_' 应该是标识符 '(_key_, _value_)' 表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42225617/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com