Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .then((item, attachments) => {
- let promises = [];
- attachments.forEach(attachment => {
- promises.push(addItem(item, attachment));
- });
- return Promise.all(promises.map(promise => { promise.catch(e => console.log(e)); }));
- })
- .then(() => { return getIems(); })
- .then(items => $scope.items = items);
- function addItem(item, attachment){
- let url = '';
- return Upload.upload({
- url: url,
- data: {attachment: attachment, model: Upload.json(item) }
- });
- }
- public async Task<IHttpActionResult> AddItem()
- {
- try
- {
- //Здесь логика проверки и сохранения файла
- return Ok();
- }
- catch
- {
- return BadRequest
- }
- }
- .then((item, attachments) => {
- let promises = attachments.map(attachment => {
- return addItem(item, attachment));
- });
- return $q.all(promises);
- })
- .then(() => {
- $scope.items = getIems()
- })
- .catch(console.error);
Add Comment
Please, Sign In to add comment