Hey there! I currently have a dropdown list featuring various animals. Here is the code snippet:
$scope.animals = [
{value:'lion', name:'lion', description: 'lion'},
{value:'cat', name:'cat', description: 'cat'},
{value:'dog', name:'dog', description: 'dog'},
];
My objective is to pass the selected value from the dropdown as contextscope to another directive. Check out this example:
<md-select ng-model="context">
<md-option ng-repeat="animal in animals" value="{{animal.value}}" aria-label="{{animal.name}}">{{animal.name}}</md-option>
</md-select>
<div described-type flex="70" contextscope="context"></div>
Within the described-type directive, I am including a field for adding descriptions like so:
<input ng-model="context.description" name="context.description">
However, I'm encountering an error that states: "Cannot create property 'description' on string 'lion'". What I actually desire is a JSON format similar to this:
"lion" : {
"description": "wild animal"
}
Any ideas on how I can resolve this error and effectively create the desired JSON structure?