Elad Noty
Elad Noty

Reputation: 237

How to close modal with a "Cancel" button with angular js and Bootstrap

I want to close the modal with the "Cancel" button

open the modal , in the controller:

    $scope.newTransaction = function(){
    var modalInstance = $modal.open({
        templateUrl: 'tpl/transactions/modal/new_transaction.html'
    });
};

the modal :

<div ng-controller="TransactionsCtrl">

    <div class="modal-header bg-success">
        <h3 class="modal-title">New Transaction</h3>
    </div>

    <div class="modal-body" style="height: 500px;">

        <iframe ng-src="{{mylink_newTransaction}}" height="100%" width="100%" frameBorder="0">  
        </iframe>
    </div>

    <div class="modal-footer bg-light">                  
        <button class="btn btn-default">Cancel</button>
        <button class="btn btn-success">Create</button>
    </div>

</div>

thanks for the help!

Upvotes: 0

Views: 4342

Answers (3)

Danield
Danield

Reputation: 125591

The documentation uses: ng-click="cancel()"

So in your case the button should look like this:

<button class="btn btn-default" ng-click="cancel()>Cancel</button>

plunker (from same documentation)

Upvotes: 0

hillai
hillai

Reputation: 93

Just add a data-dismiss attribute:

<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>

Upvotes: 0

hon2a
hon2a

Reputation: 7214

<button ng-click="$close()">Cancel</button>

See documentation.

Upvotes: 2

Related Questions