Skip to content

Instantly share code, notes, and snippets.

@icfantv
Last active January 11, 2016 17:50
Show Gist options
  • Save icfantv/1d06effd3bcd2106bb83 to your computer and use it in GitHub Desktop.
Save icfantv/1d06effd3bcd2106bb83 to your computer and use it in GitHub Desktop.
Modal Example
function ModalController($scope, $uibModalInstance) {
$scope.data = {};
$scope.data.form = {};
$scope.close = function() {
$uibModalInstace.close($scope.data.form);
}
$scope.cancel = function() {
$uibModalInstance.dismiss();
}
}
function EditController($scope) {
// do stuff with your edit form but make sure it's bound to $scope.data.form,
// or data.form in your view
}
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Some Title
</h3>
</div>
<div class="panel-body">
<div ng-controller="EditController">
<!-- do your editing stuff here, maybe via ng-include to reuse your template-->
<!-- make sure you reference your form via `data.form` -->
</div>
</div>
<div class="modal-footer">
<button class="btn btn-primary"
ng-disabled="!data.form.$dirty || data.form.$invalid"
ng-click="ModalController.save()">
Save
</button>
<button class="btn btn-danger" ng-click="cancel()">Cancel</button>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment