2

Here is the code, ideally i should see

parent: true

when I click the toggle

However, it doesn't work

Here is the plunker

<body ng-controller="MainCtrl">
  <button type="button" ng-click='isParentShown= !isParentShown' >Toggle</button>
  <div><span>Controller-isParentShown: {{isParentShown}}</span></div>
  <parent isShown='isParentShown'></parent>

</body>


var app = angular.module('plunker', []).directive('parent',function(){
    return {
        restrict: 'E',
        replace: true,
        scope: {
                isShown: '='
        },
        template: '<span>Parent: {{isShown}}</span>'
    };
}).directive('child',function(){
    return {
        restrict: 'E',
        replace: true,
        template:'<span>Child: {{isChildShown}}</span>',
        scope: {
                isChildShown: '@'
        }
    };
});
app.controller('MainCtrl', function($scope) {
  $scope.isParentShown = false;
});
1
  • The title of the question should be something about scope configuration in directives, the problem is not specific to nested directives Commented Oct 26, 2012 at 20:57

1 Answer 1

3

The problem is in the casing of the attributes, if you define a isShown binding, it's expecting a is-shown or is:shown attribute. Here's the fixed plunker: http://plnkr.co/edit/UOigth

Sign up to request clarification or add additional context in comments.

2 Comments

OMG, I am going to kill myself. What a stupid question ! Thanks for helping
No problem, happens to everyone ;)

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.