Tek
Tek

Reputation: 27

Dart- How to convert map data into form by angular dart interface?

I have a map data like following:

{
"RecipeID"   :"000682",
"RecipeName" :"My favaorite one",
"UpdateUser" :"Tek"
}

How should I convert map into form including label and text input, for example,

   Label (key)   :  Text Input(value)
 - RecipeID      :  _______________  
 - RecipeName    :  _______________
 - UpdateUser    :  _______________

I tried following method, but it seems fail.

<span ng-model="selectedRecipe">
  <form ng-repeat="items in selectedRecipe">
    <label>items[keys]</label>
    <input type="text" ng-model="items[values]"></input>
  </form>
</span>

Upvotes: 0

Views: 192

Answers (1)

Mike
Mike

Reputation: 768

Assuming selectedRecipe is Map<String,String>, and to workaround this issue, add a getter to access keys of your Map as Iterable:

get selectedRecipeKeys => selectedRecipe.keys;

And then, you can use it in ng-repeat this way:

<span ng-model="selectedRecipe">
  <form ng-repeat="key in selectedRecipeKeys">
    <label>{{key}}</label>
    <input type="text" ng-model="selectedRecipe[key]">
  </form>
</span>

Upvotes: 1

Related Questions