0

Scenario:

I do not want to open more than 3 chat windows on my page. Although I am able to manage that partially, what I want to achieve now is

to show USER buttons again if any chat window is closed (so that the user can again open a chat window if he closes any one of three)

Here is the working plunker . I have taken care of two-way binding

I am handling that in this link function:

link: function(scope, element, attr) {
  scope.close = function (){
       element.hide();
       alert('scope.count not reducing the actual count on  index.html')
       scope.count--; // <-- THIS IS NOT DECRESING THE COUNT on main index.html
  }  
  scope.$watch('box2', function(newIsOpenVal, oldIsOpenVal){
    if(newIsOpenVal !== oldIsOpenVal){
      element.find("#msg").toggle();
    }
  });

}
3
  • I see no two-way binding, but I do see isolated scope between two directives. Commented Oct 12, 2016 at 15:22
  • @Makoto: i have kept count: '=' in isolated scopes Commented Oct 12, 2016 at 15:27
  • Yes, hence why I'm not seeing any two-way binding between the two. They're effectively cut off from each other. Commented Oct 12, 2016 at 15:28

1 Answer 1

1

the problem in your implementation is that you are not using the count from your controller's scope, to solve it you should do :

$compile("<div chat-toggle user-name="+scope.userName+" count='count'></div>")(scope)
Sign up to request clarification or add additional context in comments.

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.