Globally configuring Angular directives

2019-02-11 17:43发布

Some of the Angular UI Bootstrap directives, such as datepicker, have configuration instructions like this: "All settings can be provided as attributes in the <datepicker> or globally configured through the datepickerConfig."

Although the configuration options are listed, there is no description of what a *Config is and how I globally configure one. It sounds like this is a standard part of Angular. Is it? How do I use this configuration pattern, and where is it documented?

2条回答
Luminary・发光体
2楼-- · 2019-02-11 18:23

The reference documentation for using config is in the Angular.Module type under the config method. However, that documentation doesn't tell you how config works. For an overview, look in the Developer Guide under Provider Recipe.

查看更多
做自己的国王
3楼-- · 2019-02-11 18:29

Something like this:

angular.module('myModule', ['ui.bootstrap'])

.config(['uibDatepickerConfig', function(uibDatepickerConfig) {
    uibDatepickerConfig.showWeeks = false;
}]);
查看更多
登录 后发表回答