The framework has bunch of built-in directives. We can create our own reusable components!
Register a new directive into our module
It's the same process that we use for the controller; however, the directives require the creation of something called Directive Definition Object that will be used to configure the directive's behavior:
parking.directive("directiveName", function() {
return {};
});
Creating a Alert using custom directive:-
Below is the code for alert. We need to transform this code into a reusable directive using the following directive configuration properties:
template
,
templateUrl
,
replace
,
restrict
,
scope
, and
transclude
:
snippet
<div class="alert">
<span class="alert-topic">
Something went wrong!
</span>
<span class="alert-description">
You must inform the plate and the color of the car!
</span>
</div>