我想对角度js中的动态创建下拉列表进行验证。 在这里,我通过我的JSON数据并动态创建下拉字段并能够获得偶数数据,但我希望验证默认选项“选择类型”。 .html文件
<div ng-repeat="CategoryList1 in Data">
{{CategoryList1.fullImage}}
<div ng-repeat="Attributes in CategoryList1.Attributes">
<label class="item item-input">
<span> {{Attributes.name}}</span>
</label>
<select ng-model="atcStatusTasks" name="category-group" id="name" required
ng-options="values.values for values in Attributes.Values" ng-change="atcStatusTasks===undefined ||GetValue(atcStatusTasks,Attributes.name)" >
<option selected="selected" value="">select a type</option>
</select>
{{atcStatusTasks}}{{Attributes.name}}
</div>
<button class="button button-dark" ng-click="addToCart()"> Add To Cart</button>
<span style="color:red">{{msg}}</span><br />
</div>
JSON数据:
{
"recordSetTotal": "1",
"resourceId": "",
"resourceName": "productview",
"recordSetComplete": "true",
"recordSetStartNumber": "0",
"CatalogEntryView": [
{
"shortDescription": "Straight leg denim jeans",
"buyable": "true",
"longDescription": "A regular pair of jeans for your boy in dark blue, they are straight legged and have a distressed finish. Whisker washed for a faded effect, the comfortable fit makes him look tall and lean. A white shirt goes very well with these jeans.",
"parentCategoryID": "10024",
"metaKeyword": " Hermitage Collection",
"resourceId": "",
"Price": [
{
"priceDescription": "I",
"priceUsage": "Offer",
"priceValue": "45.0"
}
],
"productType": "ProductBean",
"name": "Hermitage Straight Leg Denim Jeans",
"fullImage": "",
"thumbnail": "",
"uniqueID": "12390",
"manufacturer": "Hermitage Collection",
"numberOfSKUs": "4",
"SKUs": [
{
"Attributes": [
{
"usage": "Defining",
"Values": [
{
"values": "Blue",
"identifier": "Blue",
"uniqueID": "7000000000000001341"
}
],
"searchable": "false",
"identifier": "BoysPantsColor",
"comparable": "true",
"name": "Color",
"displayable": "true",
"uniqueID": "7000000000000000060"
},
{
"usage": "Defining",
"Values": [
{
"values": "S",
"identifier": "S",
"uniqueID": "7000000000000001344"
}
],
"searchable": "false",
"identifier": "BoysPantsSize",
"comparable": "true",
"name": "Size",
"displayable": "true",
"uniqueID": "7000000000000000061"
}
],
"SKUUniqueID": "12391",
"Price": [
{
"SKUPriceDescription": "I",
"SKUPriceValue": "45.0",
"SKUPriceUsage": "Offer"
}
]
},
{
"Attributes": [
{
"usage": "Defining",
"Values": [
{
"values": "Blue",
"identifier": "Blue",
"uniqueID": "7000000000000001341"
}
],
"searchable": "false",
"identifier": "BoysPantsColor",
"comparable": "true",
"name": "Color",
"displayable": "true",
"uniqueID": "7000000000000000060"
},
{
"usage": "Defining",
"Values": [
{
"values": "M",
"identifier": "M",
"uniqueID": "7000000000000001345"
}
],
"searchable": "false",
"identifier": "BoysPantsSize",
"comparable": "true",
"name": "Size",
"displayable": "true",
"uniqueID": "7000000000000000061"
}
],
"SKUUniqueID": "12392",
"Price": [
{
"SKUPriceDescription": "I",
"SKUPriceValue": "45.0",
"SKUPriceUsage": "Offer"
}
]
},
{
"Attributes": [
{
"usage": "Defining",
"Values": [
{
"values": "Blue",
"identifier": "Blue",
"uniqueID": "7000000000000001341"
}
],
"searchable": "false",
"identifier": "BoysPantsColor",
"comparable": "true",
"name": "Color",
"displayable": "true",
"uniqueID": "7000000000000000060"
},
{
"usage": "Defining",
"Values": [
{
"values": "L",
"identifier": "L",
"uniqueID": "7000000000000001346"
}
],
"searchable": "false",
"identifier": "BoysPantsSize",
"comparable": "true",
"name": "Size",
"displayable": "true",
"uniqueID": "7000000000000000061"
}
],
"SKUUniqueID": "12393",
"Price": [
{
"SKUPriceDescription": "I",
"SKUPriceValue": "45.0",
"SKUPriceUsage": "Offer"
}
]
},
{
"Attributes": [
{
"usage": "Defining",
"Values": [
{
"values": "Blue",
"identifier": "Blue",
"uniqueID": "7000000000000001341"
}
],
"searchable": "false",
"identifier": "BoysPantsColor",
"comparable": "true",
"name": "Color",
"displayable": "true",
"uniqueID": "7000000000000000060"
},
{
"usage": "Defining",
"Values": [
{
"values": "XL",
"identifier": "XL",
"uniqueID": "7000000000000001347"
}
],
"searchable": "false",
"identifier": "BoysPantsSize",
"comparable": "true",
"name": "Size",
"displayable": "true",
"uniqueID": "7000000000000000061"
}
],
"SKUUniqueID": "12394",
"Price": [
{
"SKUPriceDescription": "I",
"SKUPriceValue": "45.0",
"SKUPriceUsage": "Offer"
}
]
}],
"Attributes": [
{
"usage": "Defining",
"Values": [
{
"values": "S",
"extendedValue": [
{
"value": "C62",
"key": "UnitOfMeasure"
}
],
"identifier": "S",
"uniqueID": "7000000000000001344"
},
{
"values": "M",
"extendedValue": [
{
"value": "C62",
"key": "UnitOfMeasure"
}
],
"identifier": "M",
"uniqueID": "7000000000000001345"
},
{
"values": "L",
"extendedValue": [
{
"value": "C62",
"key": "UnitOfMeasure"
}
],
"identifier": "L",
"uniqueID": "7000000000000001346"
},
{
"values": "XL",
"extendedValue": [
{
"value": "C62",
"key": "UnitOfMeasure"
}
],
"identifier": "XL",
"uniqueID": "7000000000000001347"
}
],
"searchable": "false",
"dataType": "STRING",
"ExtendedValue": [
{
"extValue": "C62"
}
],
"identifier": "BoysPantsSize",
"comparable": "true",
"name": "Size",
"description": "Size",
"displayable": "true",
"uniqueID": "7000000000000000061"
},
{
"usage": "Defining",
"Values": [
{
"values": "Blue",
"extendedValue": [{
"value": "C62",
"key": "UnitOfMeasure"
}],
"identifier": "Blue",
"uniqueID": "7000000000000001341"
}
],
"searchable": "false",
"dataType": "STRING",
"ExtendedValue": [
{
"extValue": "C62"
}
],
"identifier": "BoysPantsColor",
"comparable": "true",
"name": "Color",
"description": "Color",
"displayable": "true",
"uniqueID": "7000000000000000060"
},
{
"usage": "Descriptive",
"Values": [
{
"values": "Denim jeans",
"identifier": "BCL015_1501",
"uniqueID": "7000000000000001368"
}
],
"searchable": "false",
"dataType": "STRING",
"ExtendedValue": [
{
"extValue": "C62"
}
],
"identifier": "Style",
"comparable": "true",
"name": "Style",
"description": "Style",
"displayable": "true",
"uniqueID": "7000000000000000010"
},
{
"usage": "Descriptive",
"Values": [
{
"values": "Denim",
"identifier": "BCL015_1501",
"uniqueID": "7000000000000001358"
}
],
"searchable": "false",
"dataType": "STRING",
"ExtendedValue": [
{
"extValue": "C62"
}
],
"identifier": "Material",
"comparable": "true",
"name": "Material",
"description": "Material",
"displayable": "true",
"uniqueID": "7000000000000000009"
},
{
"usage": "Descriptive",
"Values": [
{
"values": "Casual",
"identifier": "BCL015_1501",
"uniqueID": "7000000000000001378"
}
],
"searchable": "false",
"dataType": "STRING",
"ExtendedValue": [
{
"extValue": "C62"
}
],
"identifier": "Occasion",
"comparable": "true",
"name": "Occasion",
"description": "Occasion",
"displayable": "true",
"uniqueID": "7000000000000000011"
},
{
"usage": "Descriptive",
"Values": [
{
"values": "8-16",
"identifier": "BCL015_1501",
"uniqueID": "7000000000000001348"
}
],
"searchable": "false",
"dataType": "STRING",
"ExtendedValue": [
{
"extValue": "C62"
}
],
"identifier": "Age",
"comparable": "true",
"name": "Age",
"description": "Age",
"displayable": "true",
"uniqueID": "7000000000000000053"
}
],
"subscriptionType": "NONE",
"metaDescription": "Straight leg denim jeans",
"title": "Hermitage Straight Leg Denim Jeans | Aurora",
"disallowRecOrder": "true",
"hasSingleSKU": "false",
"partNumber": "BCL015_1501",
"storeID": "10001",
"fullImageAltDescription": "Image for Hermitage Straight Leg Denim Jeans from Aurora"
}
],
"recordSetCount": "1",
"MetaData": [
{
"metaKey": "price",
"metaData": "1"
}
]
}