Here is the HTML code snippet I am currently working with:
<select ng-controller="category" ng-model="selectedTestAccount" ng-options="c.category for c in categories track by c.categoryID" ></select>
<select ng-controller="subcategory" ng-model="selectedTestAccount1" ng-options="c.subcategory for c in subcategories track by c.subcategoryID"></select>
I have structured my JSON data like this:
JSON1:
{"category": "Restaurants", "categoryID": "1"}
JSON2:
{"category": "Restaurants", "categoryID": "1", "subcategory": "European", "subcategoryID": "1"}
{"category": "Restaurants", "categoryID": "1", "subcategory": "Food Carts", "subcategoryID": "17"}
I would like to create two dropdowns. The first dropdown should display categories from the first JSON. Upon selecting a category, I want the second dropdown to dynamically list subcategories from the second JSON related to the selected category. How can I make the first dropdown mandatory? Any assistance would be greatly appreciated.