Skip to content

Instantly share code, notes, and snippets.

@vistajess
Created April 6, 2017 14:19
Show Gist options
  • Select an option

  • Save vistajess/31084cf2fd68cc30cb6508b5c1598d69 to your computer and use it in GitHub Desktop.

Select an option

Save vistajess/31084cf2fd68cc30cb6508b5c1598d69 to your computer and use it in GitHub Desktop.

Revisions

  1. vistajess created this gist Apr 6, 2017.
    38 changes: 38 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    //UI Component
    <topbar-menu is-valet-online="$ctrl.isValetOnline" change-status-func="$ctrl.toggleVisibilityStatus()"></topbar-menu>

    // JS Code

    'use strict';
    class ValetDashboardController {
    /*@ngInject*/
    constructor($q, $scope, $cookies , Pusher) {

    this.isValetOnline = false;
    this.Pusher = Pusher;
    this.toggleVisibilityStatus = this.toggleVisibilityStatus.bind(this)
    }

    // ========================== UI RELATED ==================
    PusherListenIncomingAndCancelling() {
    //....
    }
    toggleVisibilityStatus() {
    this.isValetOnline = !this.isValetOnline;
    this.checkVisibility(this.isValetOnline)
    }

    checkVisibility(bool) {
    bool ? this.PusherListenIncomingAndCancelling() : this.Pusher.unsubscribe(`valet-station-${this.valetDetails.garages_id}`);
    }

    }

    ValetDashboardController.$inject = [
    '$q',
    '$scope',
    '$cookies',
    'Pusher',
    ];
    export default ValetDashboardController;