-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#2 create folder in the folder and file in the project
- Loading branch information
1 parent
0482f88
commit 857e127
Showing
29 changed files
with
580 additions
and
128 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
54 changes: 54 additions & 0 deletions
54
viDoc/modules/articles/client/services/articles-project.client.service.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
(function () { | ||
'use strict'; | ||
|
||
angular | ||
.module('articles.services') | ||
.factory('ArticlesServiceProject', ArticlesServiceProject); | ||
|
||
ArticlesServiceProject.$inject = ['$resource', '$log']; | ||
|
||
function ArticlesServiceProject($resource, $log) { | ||
var Article = $resource('/api/projects/:projectId/articles/:articleId', { | ||
projectId: '@project', | ||
articleId: '@_id' | ||
}, { | ||
update: { | ||
method: 'PUT' | ||
} | ||
}); | ||
|
||
angular.extend(Article.prototype, { | ||
createOrUpdate: function () { | ||
var article = this; | ||
return createOrUpdate(article); | ||
} | ||
}); | ||
|
||
return Article; | ||
|
||
function createOrUpdate(article) { | ||
if (article._id) { | ||
return article.$update(onSuccess, onError); | ||
} else { | ||
return article.$save(onSuccess, onError); | ||
} | ||
|
||
// Handle successful response | ||
function onSuccess(article) { | ||
// Any required internal processing from inside the service, goes here. | ||
} | ||
|
||
// Handle error response | ||
function onError(errorResponse) { | ||
var error = errorResponse.data; | ||
// Handle error internally | ||
handleError(error); | ||
} | ||
} | ||
|
||
function handleError(error) { | ||
// Log error | ||
$log.error(error); | ||
} | ||
} | ||
}()); |
This file contains 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
This file contains 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
Oops, something went wrong.