在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):jsmodules/angular-material-calendar开源软件地址(OpenSource Url):https://github.com/jsmodules/angular-material-calendar开源编程语言(OpenSource Language):HTML 50.4%开源软件介绍(OpenSource Introduction):AngularJS Material CalendarA calendar directive for AngularJS and Angular Material Design. It's lightweight at ~2.1 kB, and has a lot of configurability. InstallationRawGit<script src="https://cdn.rawgit.com/bradberger/angular-material-calendar/master/dist/angular-material-calendar.js"></script> BowerInstall it via Bower bower install --save material-calendar Or add it to your dependencies in your {
"dependencies": {
"material-calendar": "~0.2"
}
} NPMnpm install --save angular-material-calendar UsageFirst off, check out the demo. The documentation still needs to be written. It should be pretty
straight forward to figure out if you're brave by using the
Long story short, though, it's much improved by using dedicated
click handlers, setting a By default, the standard CSS and template are included in the single
compiled JavaScript file, so if you're just looking to kick the tires,
that's all you should need to use. The default template is in
<calendar-md flex layout layout-fill
calendar-direction="direction"
on-prev-month="prevMonth"
on-next-month="nextMonth"
on-day-click="dayClick"
title-format="'MMMM y'"
ng-model='selectedDate'
day-format="'d'"
day-label-format="'EEE'"
day-label-tooltip-format="'EEEE'"
day-tooltip-format="'fullDate'"
week-starts-on="firstDayOfWeek"
day-content="setDayContent"></calendar-md> The related scope looks like this: angular.module("materialExample").controller("calendarCtrl", function($scope, $filter) {
$scope.selectedDate = null;
$scope.firstDayOfWeek = 0;
$scope.setDirection = function(direction) {
$scope.direction = direction;
};
$scope.dayClick = function(date) {
$scope.msg = "You clicked " + $filter("date")(date, "MMM d, y h:mm:ss a Z");
};
$scope.prevMonth = function(data) {
$scope.msg = "You clicked (prev) month " + data.month + ", " + data.year;
};
$scope.nextMonth = function(data) {
$scope.msg = "You clicked (next) month " + data.month + ", " + data.year;
};
$scope.setDayContent = function(date) {
// You would inject any HTML you wanted for
// that particular date here.
return "<p></p>";
};
}); LocalizationThe localization of the calendar is straightforward and follows the standard Angular localization process described in the guide. You can find the list of natively supported locales here. To translate the calendar, just include the correct localization file in your web page, right after the inclusion of angular.js. You can install it by downloading the file manually or using either npm or bower to automate the download. npm install angular-i18n or bower install angular-i18n Then use the script tag to include the translations (for example, for spanish locale): <script src="bower_components/angular-i18n/angular-locale_es-es.js"></script> Another option is to use directly a CDN like cdnjs: <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/angular-i18n/1.5.7/angular-locale_es-es.js"></script> That's all, now the calendar will be automatically translated in the language of you choice. Hacking On ItUse gulp to spin up the server and re-compile resources on the fly. The
gulp ./node_modules/protractor/bin/webdriver-manager update # In one terminal
webdriver-manager start # In separate terminal
gulp Protractor is set up to run all the tests during development. JavaScript code
is linted with Unit tests are thanks to Karma, so run those at the same time while developing. They'll detect code changes and run automatically in the background: # In another terminal
karma start ContributingPull requests are most welcomed! The build process requires strict linting of code, so please follow the established ESLint style guide. Also, the first round of the directive was just a proof-of-concept and test coverage is not complete, please do add tests for all new features and bug-fixes, too! Most submissions won't be merged without a test. Also, if you could kindly add an extra test that's not related to your submission just to help us get to 100% coverage, that would be very much appreciated! To Do
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论