Reputation: 46740
With Angular I used to be able to do this
var title = 'title';
var messageBody = 'message';
var buttons = [{ result: 'ok', label: 'OK', cssClass: 'btn-primary' }];
$dialog.messageBox(title, messageBody, buttons).open();
But now, $dialog has been replaced with $modal.
What is the equivalent of the above in the new scheme?
Upvotes: 0
Views: 273
Reputation: 2477
Using $modal:
Example HTML:
<div>
<div class="modal-header">
<h3 class="modal-title">{{data.title}}</h3>
</div>
<div class="modal-body">
{{data.message}}
</div>
<div class="modal-footer">
<button class="btn-primary" ng-click="ok()">Ok</button>
</div>
</div>
Example JS:
var MyModalCtrl = function ($scope, $modal) {
$scope.title = 'I'm a Modal';
$scope.message = 'Hello World';
$scope.open = function () {
var modalInstance = $modal.open({
templateUrl: '/path/to/html',
controller: MyModalInstanceCtrl,
size: 'lg',
resolve: {
data: function () {
return {title: $scope.title, message: $scope.message};
}
}
});
modalInstance.result.then(function (selectedItem) {
console.log('Closed');
});
};
var MyModalInstanceCtrl = function ($scope, $modalInstance, data) {
$scope.data = data;
$scope.ok = function () {
$modalInstance.close();
};
};
The documentation for this can be found here: http://angular-ui.github.io/bootstrap/
Upvotes: 1