diff --git a/angular-timezone-selector.js b/angular-timezone-selector.js
index c05c66f..485f6bd 100644
--- a/angular-timezone-selector.js
+++ b/angular-timezone-selector.js
@@ -30,14 +30,19 @@ angular.module('angular-timezone-selector', [])
})
return codeMap
}])
- .directive('timezoneSelect', ['_', 'timezones', 'zoneToCC', 'CCToCountryName', function (_, timezones, zoneToCC, CCToCountryName) {
+ .directive('timezoneSelector', ['_', 'timezones', 'zoneToCC', 'CCToCountryName', function (_, timezones, zoneToCC, CCToCountryName) {
return {
restrict: 'E',
- template: '',
replace: true,
- link: function (scope, elem, attrs) {
+ template: '',
+ // require: 'ngModel',
+ scope: {
+ ngModel: '='
+ },
+ link: function ($scope, elem, attrs) {
var data = []
-
+
+
// Group the timezones by their country code
var timezonesGroupedByCC = {}
_.forEach(timezones, function (timezone) {
@@ -50,49 +55,34 @@ angular.module('angular-timezone-selector', [])
// Add the grouped countries to the data array with their country name as the group option
_.forEach(timezonesGroupedByCC, function (zonesByCountry, CC) {
- var countryName = CCToCountryName[CC]
-
- // var searchTerms = countryName.toUpperCase() + ' ' + CC + ' '
- // _.forEach(zonesByCountry, function (zone, key) {
- // console.log(zone + ' ' + key)
- // searchTerms += ' ' + zone.id.toUpperCase()
- // })
-
var zonesForCountry = {
- text: countryName,
- children: zonesByCountry,
- searchTerms: countryName
+ text: CCToCountryName[CC],
+ children: zonesByCountry
}
data.push(zonesForCountry)
})
+ // Construct a select box with the timezones grouped by country
_.forEach(data, function (group) {
var $optgroup = $('