Imagine the number of times you have had the same snippet of the HTML code repeated over your application code. In the following code snippet, we are going to create a new directive with the code to reuse this:

<div alert></div>
parking.directive("alert", function() {
return {
template: "<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>" +
The output, after AngularJS has compiled the directive, is the following:
<div alert="">
<div class="alert">
<span class="alert-topic">
Something went wrong!
<span class="alert-description">
You must inform the plate and the color of the car!
Related Tutorial
9 scope
11 link
12 require
14 compile
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #