Skip to content

Commit

Permalink
Save to gist update
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthropic committed Mar 30, 2017
1 parent f024fb0 commit 97cf839
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions examples/example.html
Expand Up @@ -270,7 +270,7 @@ <h3>Schema</h3>
// Load data from gist.
if (window.location.hash.length > 4) {
$scope.navbarMode = 'loaded';
var gistId = window.location.hash.replace(/[\#\/]*/g, '');
var gistId = window.location.hash.replace(/[\!\#\/]*/g, '');
$scope.loading = true;
$http.get('https://api.github.com/gists/' + gistId)
.then(function(response) {
Expand Down Expand Up @@ -377,16 +377,20 @@ <h3>Schema</h3>
};

$http.post('https://api.github.com/gists', gist)
.then(function(data) {
$scope.error = null;
$location.hash(data.id);
$scope.savedGistData = {
data: data,
url: $location.absUrl()
};
}, function() {
$scope.error = 'Failed to save gist.';
});
.then(function(response) {
$scope.error = null;
//$location.hash(response.data.id);
window.location.hash = response.data.id;
window.location.hash = response.data.id;
$scope.savedGistData = {
data: response.data,
url: $location.absUrl()
};
},
function() {
$scope.error = 'Failed to save gist.';
}
);
};

$scope.submitForm = function(form) {
Expand Down

0 comments on commit 97cf839

Please sign in to comment.