Skip to content

Instantly share code, notes, and snippets.

@leon
Created May 22, 2013 21:00
Show Gist options
  • Save leon/5630861 to your computer and use it in GitHub Desktop.
Save leon/5630861 to your computer and use it in GitHub Desktop.
UI-Routes show ui-dialog on route
.state("items.add", {
url: "/add",
onEnter: function($stateParams, $state, $dialog, $resource) {
var Item = $resource(...);
$dialog.dialog({
keyboard: true,
templateUrl: "items/add",
backdropClick: false,
dialogFade: true,
controller: ['$scope', function($scope) {
angular.extend($scope, {
title: "Create new item",
button: "Add",
campaign: new Item(),
$stateParams: $stateParams,
$state: $state,
save: function() {
var self = $scope;
this.item.$save(function() {
self.$emit('items.refresh');
$state.transitionTo('items');
});
}
});
}]
}).open().then(function(result) {
if (!result) {
return $state.transitionTo("items");
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment