Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Globally configuring Angular directives

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?

like image 305
Edward Brey Avatar asked Feb 14 '14 17:02

Edward Brey


People also ask

How many types of directives are there in Angular?

The three types of directives in Angular are attribute directives, structural directives, and components.

Can we use multiple directives in Angular?

You can not use two structural directives on the same element. You need to wrap your element in another one. It's advised to use ng-container since it wont be rendered in DOM.


2 Answers

Something like this:

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

.config(['uibDatepickerConfig', function(uibDatepickerConfig) {
    uibDatepickerConfig.showWeeks = false;
}]);
like image 72
Gruff Bunny Avatar answered Oct 14 '22 04:10

Gruff Bunny


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.

like image 25
Edward Brey Avatar answered Oct 14 '22 04:10

Edward Brey