| 1234567891011121314151617181920212223242526272829303132 |
- ///<reference path="../../headers/common.d.ts" />
- import angular = require('angular');
- import _ = require('lodash');
- export function ArrayJoin()
- {
- return {
- restrict: 'A',
- require: 'ngModel',
- link: function(scope, element, attr, ngModel) {
- function split_array(text) {
- return (text || '').split(',');
- }
- function join_array(text) {
- if(_.isArray(text)) {
- return (text || '').join(',');
- } else {
- return text;
- }
- }
- ngModel.$parsers.push(split_array);
- ngModel.$formatters.push(join_array);
- }
- };
- }
- angular.module('grafana.directives').directive('arrayJoin', ArrayJoin);
|