-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
AngularJS Directives Cookbook
By :
The data attribute is an important and powerful feature of HTML5. It helps us to have more control over the HTML of our application, and this is not different on AngularJS applications.
Imagine that you are working on an AngularJS application and need to validate your HTML with a validating tool. Many companies require that you ensure your HTML code is valid, by quality questions or web standards, and others simply use it as a selling point for future customers.
If you try to validate an AngularJS application, it will have some or many errors related to the ng- tags. To avoid this, we must use the following solution.
Let's use the same navbar HTML code from the previous example to show the use of the data attribute.
data- attribute before all the ng- tags:<div class="navbar navbar-default">
<div class="container">
<ul class="nav navbar-nav">
...
Change the font size
Change margin width
Change background colour