I am trying to setup the date picker to work as a month picker. Everything works as expected as long as you're clicking a month and/or going to prev/next year. However, if you want to broaden the year selection by clicking the current year from the top, I get a JavaScript error.
HTML:
<div ng-app="app">
<div ng-controller="TestController">
<input type="date" class="form-control" ng-model="date" datepicker-popup="MM/yyyy" is_open="date_opened" ng-focus="date_opened = true" ng-click="date_opened = true" datepicker-options="datepickerOptions">
</div>
</div>
JS:
(function() {
'use strict';
var app = angular.module('app', [
'ui.bootstrap'
]);
app.controller('TestController', ['$scope', function($scope) {
$scope.datepickerOptions = {
datepickerMode: "'month'",
minMode: 'month'
};
}]);
})();
Here's the JSFiddle demonstrating it (angularjs 1.2.26, ui-bootstrap 0.11.2).
Adding bootstrap using the angular. Open the file and perform the following commands, node_modules/bootstrap/dist/css/bootstrap. css in the projects->architect->build->styles array, node_modules/bootstrap/dist/js/bootstrap. js in the projects->architect->build->scripts array, node_modules/bootstrap/dist/js/bootstrap.
$uibmodal is a service to create modal windows. Uibmodal is the UI Bootstrap component written in AngularJS. It enables us to use Bootstrap in AngularJS. It provides directives for all bootstrap with some extra like, datepicker, timepicker etc.
uib-accordion-group settings heading (Default: none ) - The clickable text on the group's header. You need one to be able to click on the header for toggling. is-disabled $ (Default: false ) - Whether the accordion group is disabled or not.
The ng-app directive is a starting point of AngularJS Application. It initializes the AngularJS framework automatically. AngularJS framework will first check for ng-app directive in a HTML document after the entire document is loaded and if ng-app is found, it bootstraps itself and compiles the HTML template.
Make the following changes as highlighted in comments:
(function() {
'use strict';
var app = angular.module('app', [
'ui.bootstrap'
]);
app.controller('TestController', ['$scope', function($scope) {
$scope.datepickerOptions = {
datepickerMode: "month", // Remove Single quotes
minMode: 'month'
};
}]);
})();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With