Skip to content

Commit e28b99d

Browse files
committed
feat(configureOn): Added configureOn option that will cause this directive to re-read its configur
configureOn accepts a string which is the name of the event that will trigger the directive to re-read its configuration. -For example, perhaps the startView option in the configuration has changed and you would like the new configuration to be used. You can $broadcast the event to cause this directive to use the new configuration. closes dalelotts#204
1 parent 7448825 commit e28b99d

File tree

6 files changed

+364
-269
lines changed

6 files changed

+364
-269
lines changed

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,15 @@ Number. Default: 5
171171

172172
The increment used to build the hour view. A button is created for each <code>minuteStep</code> minutes.
173173

174+
### configureOn
175+
176+
String. Default: null
177+
178+
Causes the date/time picker to re-read its configuration when the specified event is received.
179+
180+
For example, perhaps the startView option in the configuration has changed and you would like the
181+
new configuration to be used. You can $broadcast the event to cause this directive to use the new configuration.
182+
174183
### dropdownSelector
175184

176185
When used within a Bootstrap dropdown and jQuery, the selector specified in dropdownSelector will toggle the dropdown when a date/time is selected.

demo/demo-controller.js

+19
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,24 @@ angular.module('demo.demoController', [])
6969
$scope.configFunction = function configFunction() {
7070
return {startView: 'month'};
7171
};
72+
73+
$scope.config = {
74+
configureOnConfig: {
75+
startView: 'year',
76+
configureOn: 'config-changed'
77+
}
78+
};
79+
80+
var validViews = ['year', 'month', 'day', 'hour', 'minute'];
81+
82+
$scope.changeConfig = function changeConfig() {
83+
var newIndex = validViews.indexOf($scope.config.configureOnConfig.startView) + 1;
84+
console.log(newIndex);
85+
if (newIndex >= validViews.length) {
86+
newIndex = 0;
87+
}
88+
$scope.config.configureOnConfig.startView = validViews[newIndex];
89+
$scope.$broadcast('config-changed');
90+
};
7291
}
7392
]);

0 commit comments

Comments
 (0)