generators/app/templates/client/app/components/toggle-component/toggle-component.directive.js
function toggleOpen(isOpen) {
        if (scope.isOpen === isOpen) {
          return $q.when(true);
        }
        var deferred = $q.defer();
        // Toggle value to force an async `updateIsOpen()` to run
        scope.isOpen = isOpen;
        $timeout(setElementFocus, 0, false);

        return deferred.promise;

        function setElementFocus() {
          // When the current `updateIsOpen()` animation finishes
          promise.then(function (result) {
            if (!scope.isOpen) {
              // reset focus to originating element (if available) upon close
              triggeringElement && triggeringElement.focus();
              triggeringElement = null;
            }

            deferred.resolve(result);
          });
        }
      }
function toggleOpen(isOpen) {
        if (scope.isOpen === isOpen) {
          return $q.when(true);
        }
        var deferred = $q.defer();
        // Toggle value to force an async `updateIsOpen()` to run
        scope.isOpen = isOpen;
        $timeout(setElementFocus, 0, false);

        return deferred.promise;

        function setElementFocus() {
          // When the current `updateIsOpen()` animation finishes
          promise.then(function (result) {
            if (!scope.isOpen) {
              // reset focus to originating element (if available) upon close
              triggeringElement && triggeringElement.focus();
              triggeringElement = null;
            }

            deferred.resolve(result);
          });
        }
      }
function toggleOpen ( isOpen ) { if ( scope . isOpen === isOpen ) { return $q . when ( true ) ; } var deferred = $q . defer ( ) ; // Toggle value to force an async `updateIsOpen()` to run scope . isOpen = isOpen ; $timeout ( setElementFocus , 0 , false ) ; return deferred . promise ; function setElementFocus ( ) { // When the current `updateIsOpen()` animation finishes promise . then ( function ( result ) { if ( ! scope . isOpen ) { // reset focus to originating element (if available) upon close triggeringElement && triggeringElement . focus ( ) ; triggeringElement = null ; } deferred . resolve ( result ) ; } ) ; } }
Toggle the toggleComponent view and publish a promise to be resolved when
the view animation finishes.

@param isOpen
@returns {*}
Toggle the toggleComponent view and publish a promise to be resolved when the view animation finishes .