Thanks to all who responded. They started this work in the right direction, and I was able to improve it to get the exact answer shown below.
HTML:
<div ng-controller="SwitcherCtrl"> <div data-fold-toggle="active"> <form id="login"> <input type="email" ng-model="email" required=""> <input type="password" ng-model="password" required=""> <button type="submit">Login</button> <a ng-click="active=!active">Forgot your password?</a> </form> </div> <div data-fold-toggle="active" style="display: none;"> <form id="forgotpw"> <input type="email" ng-model="email" required=""> <button type="submit">Reset Password</button> <a ng-click="active=!active">Account Access</a> </form> </div> </div>
Controller and directive:
.controller('SwitcherCtrl', function($scope) { $scope.active = true; }) .directive('foldToggle', function() { return { restrict: 'A', scope:{ isOpen: '=foldToggle' }, link: function(scope, element) { scope.$watch('isOpen', function(newVal,oldVal){ if(newVal !== oldVal){ element.toggle(200); } }); } }; });
source share