简体   繁体   中英

angularjs scope variable not updated outside directive

I'm learning directives and I have a scenario set up where I update a $scope value inside of my directive's controller. This works fine within the directive, however the $scope variable outside of the directive is not getting updated.

I have created a plunk to illustrate this behavior. In the plunk you'll see that only the scope variable gets updated inside of the directive when clicking the reset button.

Note: I tried using $scope.$apply(); as seen in another post but this does not work. It throws the apply already in progress error. I also read that this isn't a good way to do it. Could someone also mention why?

您尚未将日值发送给这样的指令:

<mydirective data-day="day"></mydirective>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM