Hi,
I am having issue with Angular custom directive code, I created sample code for 2 way binding between user control and main control, to do 2 way binding we use “=” , this is not performing in application, am I doing anything wrong?
I can able perform one way binding use “@”.
Below is my sample code.
Main CSHTM file code.
<body ng-app="directivesexample">
<div ng-controller="homecontroller">
<h3>Main Controlh3>
<input type="text" name="name" ng-model="datamodel" /> {{datamodel}}<br />
<sample-directive edit-fld1="{{datamodel}}">sample-directive>
div>
body>
Below is my AngularJs code.
var obj = angular.module('directivesexample', []);
obj.controller('homecontroller', function ($scope) {
$scope.datamodel = "sample data";
});
obj.directive('sampleDirective', function () {
var directive = {};
directive.restrict = "E";
directive.scope = {
editFld1: "="
};
directive.templateUrl = "usercontrol.html";
return directive;
});
Below is my directive(usercontrol) code.
<h3>User Controlh3>
Kindly let me know, where I am doing mistake. I am using angular JS 1.6 plugin.

ashok kallaguntaPosted May 27, 2017, 6:18 AM
Rehman Shahid : i am going to use the concept of 2 way binding in angularjs below the reference content for same.
- “@” scope: This type of scope is used for passing value to the directive scope.
- “=” scope: This type of scope is used for passing the variables instead of the scope values. The purpose of doing this is to implement two way binding in the directive.
- “&” scope: This type of scope is used for pass the value and its reference to the directives. In this scope, we can pass the expression to the directives.
i am using "=" to do the 2 way binding.