Implementing a basic component in AngularJS 1.5

The 1.5 release of AngularJS introduced a new tool: the component. While it isn't exactly similar to the concept of the Angular 2 component, it does allow you to build directive-style pieces in an explicitly componentized fashion.

Note

The code, links, and a live example related to this recipe are available at http://ngcookbook.herokuapp.com/7756/.

Getting ready

Suppose your application had a directive defined as follows:

[index.html] <div ng-app="articleApp"> <article></article> </div> [app.js] angular.module('articleApp', []) .directive('article', function() { return { controller: function() { this.person = {firstName: 'Jake'}; this.title = 'Police Bust Illegal Snail Racing Ring'; this.capitalize = ...

Get Angular 2 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.