Technologies: AngularJs and Bootstrap-ui
Enviroment: I use a collabsable filter section which is controlled by "FilterCtrl". Each input element in the filter is controlled by a nested controller like "TypeaheadCtrl" or "DatepickerCtrl". The ng-models of each one are bound with "$parent.field" in FilterCtrl.
Problem: Datepicker works fine, exept, and this is the issue, it does not close. According to the default settings (https://angular-ui.github.io/bootstrap/#/datepicker), the datepicker should close on select a date. It does not. Even if I click on the button-bar's "Close" button it does not. If the focus changes, it does close.
HTML:
<div class="" ng-controller="FilterCtrl">
<a class="black bold nodecoration" ng-click="isCollapsed = !isCollapsed" role="button">Filter</a>
<!-- Filter -->
<div class="bckgrnd-lgrey bordered max-width" collapse="isCollapsed" id="findenFilter">
<div class="nobreak" ng-controller="TypeaheadCtrl">
<label>Suchbegriff:
<input ng-model="$parent.searchText" placeholder="z.B. Rock" type="text" typeahead="prediction for prediction in predictions | filter:$viewValue |limitTo:8"></label>
</div>
<div class="nobreak" ng-controller="DatepickerCtrl">
<label>Datum:
<input class="" close-text="Close" datepicker-popup="{{format}}" is-open="status.opened" ng-click="open()" ng-model="$parent.selectedDate" show-weeks="false" type="text">
</div>
<div class="nobreak">
<label>Land: </label>
</div>
<button type="button" name="button" ng-click="printValues()">log values</button>
</div>
</div>
JS: DatepickerCtrl:
angular.module('tbdApp')
.controller('DatepickerCtrl', function($scope) {
this.awesomeThings = [
'HTML5 Boilerplate',
'AngularJS',
'Karma'
];
$scope.today = function() {
$scope.selectedDate = new Date();
};
$scope.clear = function() {
$scope.selectedDate = null;
};
$scope.open = function($event) {
$scope.status.opened = true;
};
$scope.status = {
opened: false
};
$scope.formats = ['dd.MM.yyyy', 'dd-MMMM-yyyy', 'yyyy/MM/dd'];
$scope.format = $scope.formats[0];
$scope.today();
});
FilterCtrl:
angular.module('tbdApp')
.controller('FilterCtrl', function ($scope) {
this.awesomeThings = [
'HTML5 Boilerplate',
'AngularJS',
'Karma'
];
$scope.isCollapsed = false;
$scope.selectedDate = null;
$scope.searchText = null;
$scope.printValues = function () {
console.log("collapsed: " + $scope.isCollapsed);
console.log("selectedDate: " + $scope.selectedDate);
console.log("searchText: " + $scope.searchText);
}
});
I didnt found anyone who had a similar problem. I suppose it could be a scope issue but I have no idea what excactly the issue could be.