I am new to AngularJS and could really use some help. I have a button that’s shown below that is part of a form. I need to show a modal when the form is submitted if the button is not clicked. How can I perform this check? I have tried several things with no luck.
<button ng-repeat="car in cars" btn-checkbox-false
class="btn btn-default btn-block text-left"
ng-click="AddRemoveCar(cars)">
<i ng-show="carInStock(cars)"
class="fa fa-check pull-right btn-success btn btn-xs" />
<i ng-show="!carInStock(cars)"
class="fa fa-plus pull-right btn-warning btn btn-xs" />
{{car.Model}}
</button>
2
Answers
I would be setting up some flag on the button click and check that value on form submit.
In my controller define a variable like
btnClickedFlag = false;
In Button click function:
Now on form submit , you can just check if
btnClickedFlag
istrue
if not display your modal/dialogue/overlay on screen.Consider using the UI-Bootstrap
uib-btn-checkbox
directive for your Twitter Bootstrap checkboxes.The
uib-btn-checkbox
directive, makes a group of Twitter Bootstrap buttons behave like a set of checkboxes.Then your submit function can check the state of the model as bound with the
ng-model
directive.For more information, see
The DEMO1