What is DDO (Directive Definition Object)?

Technology CommunityCategory: AngularJSWhat is DDO (Directive Definition Object)?
VietMX Staff asked 3 years ago

DDO is an object used while creating a custome directive. A standard DDO object has following parameters.

var directiveDefinitionObject = {
	priority: 0,
	template: '<div></div>', // or // function(tElement, tAttrs) { ... },
	// or
	// templateUrl: 'directive.html', // or // function(tElement, tAttrs) { ... },
	transclude: false,
	restrict: 'A',
	templateNamespace: 'html',
	scope: false,
	controller: function (
		$scope,
		$element,
		$attrs,
		$transclude,
		otherInjectables
	) { ...
	},
	controllerAs: 'stringIdentifier',
	bindToController: false,
	require: 'siblingDirectiveName', // or // ['^parentDirectiveName', '?optionalDirectiveName', '?^optionalParent'],
	compile: function compile(tElement, tAttrs, transclude) {
		return {
			pre: function preLink(scope, iElement, iAttrs, controller) { ...
			},
			post: function postLink(scope, iElement, iAttrs, controller) { ...
			}
		};
		// or
		// return function postLink( ... ) { ... }
	}
	// or
	// link: {
	//  pre: function preLink(scope, iElement, iAttrs, controller) { ... },
	//  post: function postLink(scope, iElement, iAttrs, controller) { ... }
	// }
	// or
	// link: function postLink( ... ) { ... }
};