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
import { Observable } from "rxjs/Observable"; | |
import { Injectable } from "@angular/core"; | |
import { Http, Response } from "@angular/http"; | |
import 'rxjs/add/operator/map'; | |
@Injectable() | |
export class HttpClient { | |
constructor( | |
public http: Http |
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
var app = angular.module('plunker', []); | |
app.factory('myService', function($http) { | |
return { | |
async: function() { | |
return $http.get('test.json'); //1. this returns promise | |
} | |
}; | |
}); |
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
angular.module("my-app", ['dx', 'ngFileSaver']) | |
.controller("app-ctrl", ['$scope', '$http', function ($scope, $http) { | |
$scope.downloadPDF = function downloadPDF() { | |
$http({ | |
url: 'http://localhost:3000/data', | |
method: 'GET', | |
}) | |
.then((res) => { | |
console.log(res.data.lorem); | |
$scope.pdf = 'data:application/octet-stream;base64,' + res.data.lorem; |
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
@ResponseBody | |
@RequestMapping( | |
method = RequestMethod.GET, | |
value="test", | |
produces = MediaType.APPLICATION_XML_VALUE | |
) | |
public ResponseEntity<String>testXML(){ | |
return ResponseEntity.ok("<xml></xml>); // inside use string creating xml data | |
} |
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
package com.mycompany.myapp.web.rest.controller; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import com.mycompany.myapp.models.Article; | |
import com.mycompany.myapp.repository.ArticleRepository; | |
import com.mycompany.myapp.service.ArticleService; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; |
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
function Person(first, last, age, gender, interests) { | |
this.name = { | |
first, | |
last | |
}; | |
this.age = age; | |
this.gender = gender; | |
this.interests = interests; | |
} | |
// declare |
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
/* The goal is to create function, that displays in console numbers from 0 to 9. After every number, we want little timeout.*/ | |
// this only prints 10 ten times | |
for (let i = 0; i < 10; i++) { | |
setTimeout(() => { | |
console.log(i); | |
}, i * 1000) | |
} | |
//with arrow fn, also doesn't work |
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
// super awesome keybindings for proffesionals | |
[ | |
// prevent quiting app when type | |
{ | |
"key": "ctrl+q", | |
"command": "-workbench.action.quit" | |
}, | |
// add new file when focused on sidebar | |
{ | |
"key": "ctrl+n", |
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
this.http | |
.get(url) | |
.subscribe( | |
result => { | |
this.dataStore.listItems = result; | |
this._listItems.next(result); | |
}, | |
error => { | |
console.log('error'); | |
}, |
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
let products = [ | |
{ name: "Hat", price: 24.5, stock: 10 }, | |
{ name: "Kayak", price: 289.99, stock: 1 }, | |
{ name: "Soccer Ball", price: 10, stock: 0 }, | |
{ name: "Running Shoes", price: 116.50, stock: 20 } | |
]; | |
console.log( | |
products.map(item => ({name: item.name, price: item.price * 2, stock: item.stock})) | |
) |