Exploring directives in AngularJS led me to this interesting code snippet:
var app = angular.module('app', []);
//custom directive creation
app.directive("myDir", function () {
return {
restrict: "E",
scope: {
title: '@'
//= two-way binding
I have a few questions:
In the provided code, the 'scope' attribute seems to create either a child scope or an isolated scope. How can I specify which type of scope I want for this directive? If I only want a child scope but not an isolated one, how would I achieve that?
Does 'isolated' mean that the created scope cannot access variables from the parent scope?
By default, a parent scope cannot access variables from a child scope, but if the child scope is not isolated, can it access parent variables?
Lastly, if we define a 'controller' attribute to assign a controller to this directive, will the directive automatically inherit the controller's scope?
Thank you!