Skip to content
This repository was archived by the owner on Feb 18, 2022. It is now read-only.

Commit 7cc9f3b

Browse files
committed
* Updated datepicker to respect previously set interpolation begin /
end markers.
1 parent bfa2b96 commit 7cc9f3b

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

assets/js/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@
33
(function (angular) {
44
'use strict';
55

6-
angular.module('720kb', [
6+
var app = angular.module('720kb', [
77
'ngRoute',
88
'720kb.datepicker'
99
]);
10+
11+
// Setup interpolation to use [[ / ]]
12+
app.config(function($interpolateProvider) {
13+
// Setup angular to use [[ expression ]] instead of {{ expression }}
14+
$interpolateProvider.startSymbol('[[').endSymbol(']]');
15+
});
1016
}(angular));

index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<div datepicker>
2323
<input ng-model="date1" type="text" class="angular-datepicker-input"/>
2424
</div>
25-
Date 1 is: {{date1}}
25+
Date 1 is: [[date1]]
2626
</div>
2727
<div class="col3">
2828
<div class="datepicker"
@@ -33,13 +33,13 @@
3333
button-next='<i class="fa fa-arrow-circle-right"></i>'>
3434
<input ng-model="date2" type="text" class="angular-datepicker-input"/>
3535
</div>
36-
Date 2 is: {{date2}}
36+
Date 2 is: [[date2]]
3737
</div>
3838
<div class="col3">
3939
<datepicker>
4040
<input ng-model="date3" type="text" class="angular-datepicker-input"/>
4141
</datepicker>
42-
Date 3 is: {{date3}}
42+
Date 3 is: [[date3]]
4343
</div>
4444
</div>
4545
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.4/angular.min.js"></script>

src/js/angular-datepicker.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
'use strict';
66

77
angular.module('720kb.datepicker', [])
8-
.directive('datepicker', ['$window', '$compile', '$locale', '$filter', function manageDirective($window, $compile, $locale, $filter) {
8+
.directive('datepicker', ['$window', '$compile', '$locale', '$filter', '$interpolate', function manageDirective($window, $compile, $locale, $filter, $interpolate) {
99

1010
var A_DAY_IN_MILLISECONDS = 86400000;
1111
return {
@@ -81,8 +81,11 @@
8181
'<a href="javascript:void(0)" ng-repeat="nx in nextMonthDays" class="_720kb-datepicker-calendar-day _720kb-datepicker-disabled">{{nx}}</a>' +
8282
'</div>' +
8383
'</div>' +
84-
'</div>';
84+
'</div>';
8585

86+
// Respect previously configured interpolation symbols.
87+
htmlTemplate = htmlTemplate.replace(/{{/g, $interpolate.startSymbol())
88+
.replace(/}}/g, $interpolate.endSymbol());
8689
$scope.$watch('dateSet', function dateSetWatcher(value) {
8790
if (value) {
8891
date = new Date(value);

0 commit comments

Comments
 (0)