Created
May 22, 2013 21:00
-
-
Save leon/5630861 to your computer and use it in GitHub Desktop.
UI-Routes show ui-dialog on route
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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