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
Non-linear Components In electrical circuits, Non-linear Components are electronic devices that need an external power source to operate actively. Non-Linear Components are those that are changed with respect to the voltage and current. Elements that do not follow ohm's law are called Non-linear Components. Non-linear Co
11 min read
JavaScript Tutorial JavaScript is a programming language used to create dynamic content for websites. It is a lightweight, cross-platform, and single-threaded programming language. It's an interpreted language that executes code line by line, providing more flexibility.JavaScript on Client Side: On the client side, Jav
11 min read
Web Development Web development is the process of creating, building, and maintaining websites and web applications. It involves everything from web design to programming and database management. Web development is generally divided into three core areas: Frontend Development, Backend Development, and Full Stack De
5 min read
Spring Boot Tutorial Spring Boot is a Java framework that makes it easier to create and run Java applications. It simplifies the configuration and setup process, allowing developers to focus more on writing code for their applications. This Spring Boot Tutorial is a comprehensive guide that covers both basic and advance
10 min read
React Interview Questions and Answers React is an efficient, flexible, and open-source JavaScript library that allows developers to create simple, fast, and scalable web applications. Jordan Walke, a software engineer who was working for Facebook, created React. Developers with a JavaScript background can easily develop web applications
15+ min read
React Tutorial React is a powerful JavaScript library for building fast, scalable front-end applications. Created by Facebook, it's known for its component-based structure, single-page applications (SPAs), and virtual DOM,enabling efficient UI updates and a seamless user experience.Note: The latest stable version
7 min read
JavaScript Interview Questions and Answers JavaScript is the most used programming language for developing websites, web servers, mobile applications, and many other platforms. In Both Front-end and Back-end Interviews, JavaScript was asked, and its difficulty depends upon the on your profile and company. Here, we compiled 70+ JS Interview q
15+ min read
Class Diagram | Unified Modeling Language (UML) A UML class diagram is a visual tool that represents the structure of a system by showing its classes, attributes, methods, and the relationships between them. It helps everyone involved in a projectâlike developers and designersâunderstand how the system is organized and how its components interact
12 min read
Backpropagation in Neural Network Back Propagation is also known as "Backward Propagation of Errors" is a method used to train neural network . Its goal is to reduce the difference between the modelâs predicted output and the actual output by adjusting the weights and biases in the network.It works iteratively to adjust weights and
9 min read
3-Phase Inverter An inverter is a fundamental electrical device designed primarily for the conversion of direct current into alternating current . This versatile device , also known as a variable frequency drive , plays a vital role in a wide range of applications , including variable frequency drives and high power
13 min read