Skip to content

Instantly share code, notes, and snippets.

View Kamilnaja's full-sized avatar
💭
🐍🔥

Kamil Naja Kamilnaja

💭
🐍🔥
View GitHub Profile
class House {
constructor() {
this.doors = 3;
this.windows = 10;
}
}
var myHouse = new House();
//rozszerz klase
import React from 'react'
import ReactDOM from 'react'
import { render } from 'react-dom';
class CommentBox extends React.Component {
render () {
return (
<div className = "commentBox">
hello world
</div>
@Kamilnaja
Kamilnaja / angular2 - choose item and open with more info
Created May 6, 2017 13:58
angular2 - choose item and open with more info
export class AppComponent implements OnInit {
herbs = [];
selectedHerb;
constructor(private _herbService: HerbsService){}
ngOnInit() {
this._herbService.getHerbs()
.subscribe(resHerbsData => this.herbs = resHerbsData);
}
@Kamilnaja
Kamilnaja / Angular 2 - get data from json file and display
Last active November 6, 2018 19:17
Angular 2 - get data from json file and display
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());
@Kamilnaja
Kamilnaja / Fiter items by name ANG2.ts
Last active May 6, 2017 11:27
Filter items by the name. Based on Net Ninja Tutorial
//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)"
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);
})
});
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();
<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>
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;