From 13f31602f396bc269076ab4d389cfd8ca94b20ba Mon Sep 17 00:00:00 2001 From: Vojta Jina Date: Mon, 12 Mar 2012 22:56:36 -0700 Subject: feat(ng-list): Allow custom separator --- src/directive/input.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/directive/input.js b/src/directive/input.js index 740f3ba6..631e3a36 100644 --- a/src/directive/input.js +++ b/src/directive/input.js @@ -1101,6 +1101,8 @@ var requiredDirective = [function() { * Text input that converts between comma-seperated string into an array of strings. * * @element input + * @param {string=} ng-list optional delimiter that should be used to split the value. If + * specified in form `/something/` then the value will be converted into a regular expression. * * @example @@ -1139,12 +1141,15 @@ var ngListDirective = function() { return { require: 'ngModel', link: function(scope, element, attr, ctrl) { + var match = /\/(.*)\//.exec(attr.ngList), + separator = match && new RegExp(match[1]) || attr.ngList || ','; + var parse = function(viewValue) { var list = []; if (viewValue) { - forEach(viewValue.split(/\s*,\s*/), function(value) { - if (value) list.push(value); + forEach(viewValue.split(separator), function(value) { + if (value) list.push(trim(value)); }); } -- cgit v1.2.3