December 2014
Intermediate to advanced
346 pages
6h 14m
English
Directives will frequently load HTML templates from outside their definition. When using them in an application, you will need to understand how to properly manage them, how they interact (if at all) with the directive's parent scope, and how they interact with the content nested inside them.
Suppose that you begin with the following skeleton application:
(index.html - uncompiled)
<div ng-app="myApp">
<div ng-controller="MainCtrl">
<my-directive>
Stuff inside
</my-directive>
</div>
</div>
(app.js)
angular.module('myApp', [])
.controller('MainCtrl', function ($scope) {
$scope.overwrite = false;
$scope.origin = 'parent controller';
});Introduce a template to the directive as follows:
(index.html – uncompiled) ...
Read now
Unlock full access