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 express = require('express'); | |
var http = require('http'); | |
var mysql = require('mysql'); | |
var app = express(); | |
var connection = mysql.createConnection({ | |
host: 'localhost', | |
user: 'root', | |
password: '', | |
database: 'heroes' |
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 myModule = { | |
animals: ['dog', 'cat', 'bird'], | |
addNewElement: function (newAnimal) { | |
var elementToAdd; | |
if (typeof newAnimal !== 'string') { | |
elementToAdd = document.querySelector('#animal').value(); | |
} else { | |
elementToAdd = newAnimal; | |
} |
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 ourModule = (function(){ | |
var _animals = ['dog', 'cat', 'bird']; | |
var _addNewElement = function (newAnimal) { | |
var elementToAdd; | |
if (typeof newAnimal !== 'string') { | |
elementToAdd = document.querySelector('#animal').value(); | |
} else { | |
elementToAdd = newAnimal; | |
} |
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 myInfo = "<p>My Name is {{name}} and I live at {{street}} in {{city}}, {{state}}</p>"; | |
var template = Handlebars.compile(myInfo); | |
var data = template({name: "Derek", street: "123 main", city: "Lublin", state: "Warsaw shore"}); | |
document.getElementById("kamilData").innerHTML += 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
<div id="quoteData"></div> | |
<script id="quote-template" type="text/x-handlebars-template"> | |
<h3>Favorite {{name}} Quotes</h3> | |
<ol> | |
{{#each quotes }} | |
<li>{{quote}}</li> | |
{{/each}} | |
</ol> | |
</script> | |
<script> |
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
Handlebars.registerHelper("makeLink", function(text, url) { | |
text = Handlebars.Utils.escapeExpression(text); | |
url = Handlebars.Utils.escapeExpression(url); | |
var theLink = '<a href="' + url + '">' + text + '</a>'; | |
return new Handlebars.SafeString(theLink); | |
}); |
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 xhttp = new XMLHttpRequest(); | |
xhttp.onreadystatechange = function() { | |
if (this.readyState == 4 && this.status == 200) { | |
// Typical action to be performed when the document is ready: | |
console.log(xhttp.responseText); | |
} | |
}; | |
xhttp.open("GET", "json.json", true); | |
xhttp.send(); |
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('myApp', []); | |
app.controller('myCtrl', function($scope, $http) { | |
$http.get('users.json') | |
.then(function(response) { | |
$scope.myUsers = response.data; | |
console.log($scope.myUsers.people[1].name); | |
}) | |
}); |
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
//inside template | |
<label>Filtruj po rasie</label> | |
<input type="text" name="filter" [(ngModel)]="term"/> | |
</form> | |
<div | |
*ngFor="let dog of dogs | filter:term; | |
let i = index" | |
class="puppy-wrapper" | |
(click)="onSelect(dog)" |
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 { Injectable } from '@angular/core'; | |
import { Http, Response } from '@angular/http'; | |
import 'rxjs/add/operator/map'; | |
@Injectable() | |
export class HerbsService { | |
private _url= 'assets/herbs.json'; | |
constructor(private _http: Http) {} | |
getHerbs () { | |
return this._http.get(this._url) | |
.map((response: Response) => response.json()); |
OlderNewer