What is the difference between '@' and '=' in directive scope in AngularJS ?
Last Updated :
28 Apr, 2025
AngularJS is a popular JavaScript framework, that provides powerful features for building dynamic web applications. When creating custom directives in AngularJS, you may come across the need to define a scope for your directive. The two most common methods to do this are by using the @ and = symbols. These 2 symbols are used to describe the different Binding types while defining the directives with isolated scopes. These symbols govern the passing of the data between the parent scope and the directive's isolated scope. In this article, we'll understand the '@' and '=' symbols in AngularJS, along with knowing the differences between them, and then will understand their basic implementation through the examples. Before we proceed into the differences between them, we should learn what are scopes in AngularJS.
Directives Scope
In AngularJS Directives have the ability to possess their scopes. These scopes can be inherited from the parent scope providing control over data flow and encapsulation within your directives. Directives Scope has different types of bindings that define the data flows in and out of the directive.
- Inherited Scope: This refers to a scope that uses the scope as its parent. Any changes made within the directive will affect the parent scope and vice versa. This is particularly useful when you want your directive to share data and functions, with the surrounding controller or template.
- Isolated Scope: This is the scope for a directive that operates independently from its parent. It allows for the creation of self-contained directives, with their data and functions. Isolated scopes are commonly utilized when building components.
AngularJS '@' Symbol
The @ symbol is a type of text binding or one-way binding of strings or interpolated values from the parent scope to the directive's isolated scope which allows you to pass values as text.
Syntax
scope: {
attributeName: '@'
}
Example: This example describes the basic implementation of the '@' symbol in AngularJS.
HTML
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<script src=
"https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js">
</script>
</head>
<body ng-controller="MyController">
<h2 style="color: green;">
GeeksforGeeks
</h2>
<div my-directive attribute-name="{{ msg }}"></div>
<script>
angular.module('myApp', [])
.controller('MyController', function ($scope) {
$scope.msg = 'Hello, geek!';
})
.directive('myDirective', function () {
return {
scope: {
attributeName: '@'
},
link: function (scope) {
},
template:
'<p>Directive Message using @ scope: '+
'{{ attributeName }}</p>'
};
});
</script>
</body>
</html>
Output:

AngularJS '=' Symbol
The '=' symbol is a type of two-way binding between the directive's isolated scope and the parent scope. In this scope, the changes in the directive's scope are reflected in the parent scope.
Syntax:
scope: {
attributeName: '='
}
Example: This example describes the basic implementation of the '=' symbol in AngularJS.
HTML
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<script src=
"https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js">
</script>
</head>
<body ng-controller="MyController">
<h2 style="color: green;">
GeeksforGeeks
</h2>
<div my-directive attribute-name="msg "></div>
<script>
angular.module('myApp', [])
.controller('MyController', function ($scope) {
$scope.msg = 'Hello, geek!';
})
.directive('myDirective', function () {
return {
scope: {
attributeName: '='
},
link: function (scope) {
},
template:
'<p>Directive Message using = scope:'
' {{ attributeName }}</p>'
};
});
</script>
</body>
</html>
Output:

Differences between '@' directive scope and '=' in directive Scope
'@' in directive scope
| '=' in directive scope
|
---|
The scope modification is read-only. | The scope modification is both read and write. |
This scope contains the data types of strings or interpolated values. | This scope contains variables for two-way data binding. |
It gives one-way or we can say from parent to directive. | It gives two-way or bidirectional. |
It is used where there is static content or simple data transfer. | It is used when there is dynamic data binding and synchronization. |
It is commonly used with simple text values like titles, labels, or messages. | We use this when there are interactive components with real-time updates. |
Similar Reads
What is the difference between Service Directive and Module in Angular ? Angular is a Typescript framework used to build dynamic and Single-Page Applications. This has a strong focus on modularity and reusability of code which helps in creating complex and maintainable applications. At the core, Angular has 3 fundamental building blocks, i.e., Service, Directive and Modu
6 min read
What is the Difference Between factory and service in AngularJS ? AngularJS is a JavaScript-based framework. It can be used by adding it to an HTML page using a <script> tag. AngularJS helps in extending the HTML attributes with the help of directives and binding of data to the HTML with expressions. In this article, we will explore the differences between t
4 min read
What's the difference between ng-pristine and ng-dirty in AngularJS ? AngularJS supports client-side form validation. AngularJS keeps track of all the form and input fields and it also stores the information about whether anyone has touched or modified the field or not. The two different classes ng-dirty and ng-pristine that are used for form validation, are described
2 min read
What is the difference between $watch and $observe in AngularJS ? AngularJS provides different methods to observe/watch the changes in its elements and variables. The $observe and $watch are two different methods that serve this purpose. $observe is a method that is responsible to observe/watch the changes in the DOM attribute. We use $observe when we want to obse
3 min read
What is the Difference Between $evalAsync and $timeout in AngularJS? AngularJS is a JavaScript framework, which may be utilized by including it in an HTML web page the usage of a <script> tag. AngularJS enables in extension the HTML attributes with the assistance of directives and binding of data to the HTML with expressions. It provides various tools for handl
5 min read
What is the difference between ng-if and data-ng-if directives ? The ng-if is a directive in AngularJS which is used to remove the HTML element if the value of the expression or variable is false, unlike ng-hide which just hides the HTML element from the DOM. Syntax: <element angular_directive=expression> Contents... </element> There are few other opt
2 min read
What is the Difference Between required and ng-required in AngularJS ? In web application development, AngularJS is one of the most favorite dynamic JavaScript frameworks that has HTML through script tags, enabling us to augment the HTML attributes using the directives and facilitating the data binding through the expressions.In AngularJS, we can use certain Directives
3 min read
Difference between Directive and Component in AngularJS In this article, we will see what is Directive & Components in Angular JS, along with finding the relevant differences between Directive and Components, with knowing their behavioral characteristics for building powerful Angular JS code. Directives are introduced with the invention of Angular,
4 min read
What is the difference between ng-app and data-ng-app in AngularJS ? In web application development, AngularJS is one of the most favorite dynamic JavaScript frameworks that has HTML through script tags, enabling us to augment the HTML attributes using the directives and facilitating the data binding through the expressions.In this article, we will see the concepts o
5 min read
What is the difference between properties and attributes in HTML? HTML is the standard language for creating documents that are intended to be displayed on web browsers. It is very usual to get confused with attributes and properties while performing DOM object manipulation in JavaScript. Before learning about the differences, let us first define the Document Obje
4 min read