Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

toggle button in angularjs bootstrap

<a class="btn pull-right" 
   ng-class="{true: 'btn-primary', false: 'btn-danger'}[!patient.archived]"
   ng-click="patient.archived = !patient.archived">
  {{!patient.archived && 'Archive' || 'Unarchive'}} patient
</a>
Comment

How to make a toggle button in Angularjs

$scope.toggleButton = { inAddState: true };
$scope.update = (id, button) => {
    if (button.inAddState) {
        // logic to add
    } else {
        // logic to remove
    }
    // make sure you switch the state of the button at some point
    button.inAddState = !button.inAddState;
}

<button ng-click="update(data.id, toggleButton)" 
        class="btn {{ toggleButton.inAddState ? 'btn-primary' : 'btn-warning' }}"
        ng-bind="toggleButton.inAddState ? 'Add' : 'Remove'">
</button>
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript Assigning to a non-writable property is not allowe 
Javascript :: js rename onclick function 
Javascript :: ready function jq 
Javascript :: javascript get cookie value one liner 
Javascript :: math floor javascript 
Javascript :: apply() js 
Javascript :: how to pass an image path to img src in Reactjs 
Javascript :: regex not a value 
Javascript :: scroll js 
Javascript :: is displayed 
Javascript :: remove equal json js 
Javascript :: generate svg from javascript 
Javascript :: jquery append text for 5 seconds 
Javascript :: lunix increae ram available to nodejs 
Javascript :: JQuery Autocomplete no result found 
Javascript :: JavaScript try...catch Statement 
Javascript :: how to disable security in jhipster 
Javascript :: expo location background example 
Javascript :: js intellisence not working 
Javascript :: remove cookie 
Javascript :: javascript arrays 
Javascript :: supertest formdata 
Javascript :: Get position of each element using jquery 
Javascript :: if in javascript 
Javascript :: js get target foreach 
Javascript :: repeat async call n times in js 
Javascript :: find element in array underscore js 
Javascript :: how to hide a screen from drawer in react navigation 5 
Javascript :: How to scan a folder for documents with javascript 
Javascript :: extjs clone object 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =