Skip to content

Instantly share code, notes, and snippets.

@facelordgists
Last active June 12, 2019 19:15
Show Gist options
  • Save facelordgists/ac624ecf5e592012886a696126ca16aa to your computer and use it in GitHub Desktop.
Save facelordgists/ac624ecf5e592012886a696126ca16aa to your computer and use it in GitHub Desktop.
// ===========================================================
// Simple toggle
// ----------------------------------
var bool = true;
bool = !bool;
// ===========================================================
// Function to toggle
// ----------------------------------
$scope.form_state.showing = false;
$scope.toggle = function(){
$scope.form_state.showing = !$scope.form_state.showing;
}
// ===========================================================
// Toggling capabilities wrapped into one little object
// ----------------------------------
$scope.form_state = {
showing: false,
show: function(){$scope.form_state.showing = true},
hide: function(){$scope.form_state.showing = false},
toggle: function(){
$scope.form_state.showing = !$scope.form_state.showing;
}
}
// usage
$scope.form_state.toggle();
$scope.form_state.hide();
$scope.form_state.show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment