1

I am new to angularjs. I am working with isolated scope. The two way binding using isolated scope is not working. Please check my code. If i remove age : '=' then my code is working fine.

**HTML**

<div ng-controller="homeCtrl">
    <my-dir name="{{namee}}" age="{{age}}"></my-dir>
</div>

**JS**

var app = angular.module("home")
app.controller("homeCtrl",["$scope",function($scope){
   $scope.namee = "John";
   $scope.age= 30;
}]);

app.directive("myDir",function(){
    return{
        restrict :'E',
        scope: {
            name : '@',
            age :  '=',
        },
        template: ['Directive name is: {{name}}',
                   '<p>{{age}}</p>' 
                 ]
        }
})


**Output**

John 30 
Directive name is: {{name}} {{age}}

2 Answers 2

2

It should be:

<div ng-controller="homeCtrl">
  <my-dir name="name" age="age"></my-dir>
</div>
Sign up to request clarification or add additional context in comments.

Comments

1

remove the {{}} use just age="age"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.