Book Image

AngularJS Directives Cookbook

By : Monteiro
Book Image

AngularJS Directives Cookbook

By: Monteiro

Overview of this book

AngularJS directives are at the center of what makes it such an exciting – and important - web development framework. With directives, you can take greater control over HTML elements on your web pages – they ‘direct’ Angular’s HTML compiler to behave in the way you want it to. It makes building modern web applications a much more expressive experience, and allows you to focus more closely on improving the way that user interaction impacts the DOM and the way your app manages data. If you’re already using Angular, you probably recognize the power of directives to transform the way you understand and build your projects – but customizing and creating your own directives to harness AngularJS to its full potential can be more challenging. This cookbook shows you how to do just that – it’s a valuable resource that demonstrates how to use directives at every stage in the workflow. Packed with an extensive range of solutions and tips that AngularJS developers shouldn’t do without, you’ll find out how to make the most of directives. You’ll find recipes demonstrating how to build a number of different user interface components with directives, so you can take complete control over how users interact with your application. You’ll also learn how directives can simplify the way you work by creating reusable directives – by customizing them with Yeoman you can be confident that you’re application has the robust architecture that forms the bedrock of the best user experiences. You’ll also find recipes that will help you learn how to unit test directives, so you can be confident in the reliability and performance of your application. Whether you’re looking for guidance to dive deeper into AngularJS directives, or you want a reliable resource, relevant to today’s web development challenges, AngularJS Directives Cookbook delivers everything you need in an easily accessible way.
Table of Contents (11 chapters)
10
Index

What this book covers

Throughout this book, we'll explore different ways to build AngularJS directives and understand all the elements that make up a directive.

We will cover fundamental concepts about scope, link, $compile, external templates, reusable components, and Directives Unit Testing.

Mastering how to create and customize AngularJS directives, by the end of this book you will be able to work comfortably with modular AngularJS applications using custom directives to create rich web interface components.

Although some points are advanced, you'll be prepared to understand the core concepts and how to choose or create the right directive for your project.

Chapter 1, Dealing with Modal and Tabs Directives, presents some alternatives to create simple interface components such as Modal and tabs using tips and exploring best practices to cover the most important points of creating and dealing with directives.

Chapter 2, Building a Navbar Custom Directive, focuses on building a custom navbar with menu links as a directive component. You will learn how to manipulate the DOM to show and hide user information using these custom directives and how to structure an AngularJS application to use shared components.

Chapter 3, Customizing and Using Bootstrap UI Directives, throws light on Bootstrap UI directives and explains how to extend and customize some components, exploring external templates and custom CSS customization, showing some component examples in real-case scenarios.

Chapter 4, Creating Interactive jQuery UI Directives, explains how to use jQuery and the jQuery UI to build some interface components with a comprehensive approach to how jQuery manipulates the DOM in AngularJS applications using IDs and selectors.

Chapter 5, Implementing Custom Directives with Yeoman Generators, shows how to use a Yeoman generator to create custom directives of ongoing projects, how to implement some useful directives, such as ngMap, and more.

Chapter 6, Using Directives to Develop Interface Components, demonstrates how to build a micro e-commerce application combining different types of custom directives.

Chapter 7, Building Directives with Dynamic Templates, explains how to build directives to use and load dynamic templates, provides a comparison of inline templates and external templates, explains more about the Compile function, and shows how to organize custom directives on shared folders.

Chapter 8, Creating Reusable Directives, shows how we can organize an AngularJS application and prepare it to be scalable with the use of shared directives, how to build chart directives, and explores some points about naming conventions, code organization, and best practices.

Chapter 9, Directive Unit Testing with Karma and Jasmine, covers how to configure and use Karma and Karma Runner to test custom directives using the Jasmine framework and explains how to deal with scope change and testing elements.