The modal popup opens even when the button is disabled in angularjs

I have a modal Bootstrap popup form that opens with a button click in AngularJS, I am wondering how it still displays, even if the button is disabled.

Please see the button code below:

<a class="btn btn-sm btn-info" data-toggle="modal" href="#modal-form-submit" data-backdrop="static" data-keyboard="false" ng-disabled="!ItemName || ItemDescription">
   Submit
</a>

I have below model popup code:

<div id="modal-form-submit" class="modal">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                    <h4 class="blue bigger"> DEMO MODEL FORM </h4>
                </div>
                <div class="modal-body">
                    <div class="row">
                        <div class="col-sm-12 col-xs-12">
                            <div class="form-group">
                                <label class="control-label" for="toitems">To:</label>
                                <div class="tags full-width">
                                    <span class="tag" ng-repeat="tag in tags">{{ tag.Description }}</span>
                                </div>
                            </div>
                        </div>
                    </div>                        
                </div>
                <hr />
                <div class="modal-footer">
                    <button class="btn btn-sm" data-dismiss="modal">
                        <i class="ace-icon fa fa-times"></i>
                        Cancel
                    </button>
                    <button class="btn btn-sm btn-primary " ng-disabled="!ItemCode || !ItemDescription"
                            ng-click="SaveEntireFormData()" type="button">
                        <i class="ace-icon fa fa-check"></i>
                        Confirm
                    </button>
                </div>
            </div>
        </div>
    </div>

I don't want to use jquery js, I really want to enable this with angular js.

+4
source share
4 answers

Just add a disabled anchor tag class

<a class="btn btn-sm btn-info disabled" data-toggle="modal" href="#modal-form-submit" data-backdrop="static" data-keyboard="false" ng-disabled="ItemName || ItemDescription">
+2
source

disabled anchor. , button, fieldset ..

, CSS, :

a[disabled] {
    pointer-events: none;
}
+2

I did it and worked great.

<a class="btn btn-sm btn-info" ng-class="{'disabled':(!ItemName || !ItemDescription)}" data-toggle="modal" href="#modal-form-submit" data-backdrop="static" data-keyboard="false">
0
source

try it

ng-disabled="(!ItemName) || (ItemDescription) "

if possible, plz will tell you what ItemName and ItemDescription are.

remember that in angularjs, if you want to disable any field, you must do this

ng-disabled = 'true' ;
0
source

Source: https://habr.com/ru/post/1649349/


All Articles