Index: third_party/pkg/angular/lib/formatter/arrayify.dart |
diff --git a/third_party/pkg/angular/lib/formatter/arrayify.dart b/third_party/pkg/angular/lib/formatter/arrayify.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e38bc1a34cd849d39ff5666bb6a2ef0a0c4f6303 |
--- /dev/null |
+++ b/third_party/pkg/angular/lib/formatter/arrayify.dart |
@@ -0,0 +1,27 @@ |
+part of angular.formatter_internal; |
+ |
+/** |
+ * Given a Map, returns a list of items which have `key` and `value` property. |
+ * |
+ * Usage: |
+ * |
+ * <div ng-repeat="item in {'key1': 'value1', 'key2':'value2'} | arrayify"> |
+ * {{item.key}}: {{item.value}} |
+ * </div> |
+ */ |
+@Formatter(name:'arrayify') |
+class Arrayify implements Function { |
+ List<_KeyValue> call(Map inputMap) { |
+ if (inputMap == null) return null; |
+ List<_KeyValue> result = []; |
+ inputMap.forEach((k, v) => result.add(new _KeyValue(k, v))); |
+ return result; |
+ } |
+} |
+ |
+class _KeyValue<K, V> { |
+ K key; |
+ V value; |
+ |
+ _KeyValue(this.key, this.value); |
+} |