From c46311aa2fcbb21e97f4a7736366680a5b41af17 Mon Sep 17 00:00:00 2001 From: Mikael Korpela Date: Sat, 20 Feb 2016 18:24:03 +0200 Subject: [PATCH 1/2] Add possibility to pass custom template --- src/sb-date-select.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/sb-date-select.js b/src/sb-date-select.js index a841d20..21c9f57 100644 --- a/src/sb-date-select.js +++ b/src/sb-date-select.js @@ -2,7 +2,7 @@ angular.module('sbDateSelect', []) - .directive('sbDateSelect', [function () { + .run(["$templateCache", function ($templateCache) { var template = [ '
', @@ -18,10 +18,18 @@ angular.module('sbDateSelect', []) '
' ]; + $templateCache.put("sb-date-select.html", template.join('')); + + }]) + + .directive('sbDateSelect', [function () { + return { restrict: 'A', replace: true, - template: template.join(''), + templateUrl: function ($element, $attrs) { + return $attrs.templateUrl || 'sb-date-select.html' + }, require: 'ngModel', scope: { selectClass: '@sbSelectClass' @@ -87,7 +95,7 @@ angular.module('sbDateSelect', []) if (scope.val.year && scope.val.month && max.isSame([scope.val.year, scope.val.month-1], 'month')) { maxDate = max.date(); - } else if (scope.val.year && scope.val.month) { + } else if (scope.val.year && scope.val.month) { maxDate = moment([scope.val.year, scope.val.month-1]).daysInMonth(); } else { maxDate = 31; @@ -117,4 +125,3 @@ angular.module('sbDateSelect', []) } }; }]); - From d970b4d047d2d6ae5f7969655eb1e8d3208619a7 Mon Sep 17 00:00:00 2001 From: Mikael Korpela Date: Sun, 21 Feb 2016 02:58:54 +0200 Subject: [PATCH 2/2] Unify coding style and fix commas --- src/sb-date-select.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sb-date-select.js b/src/sb-date-select.js index 21c9f57..3427c5a 100644 --- a/src/sb-date-select.js +++ b/src/sb-date-select.js @@ -2,14 +2,14 @@ angular.module('sbDateSelect', []) - .run(["$templateCache", function ($templateCache) { + .run(['$templateCache', function ($templateCache) { var template = [ '
', - '', '', '', - '', '', '', '