Skip to content

Instantly share code, notes, and snippets.

View Kamilnaja's full-sized avatar
💭
🐍🔥

Kamil Naja Kamilnaja

💭
🐍🔥
View GitHub Profile
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;
@Kamilnaja
Kamilnaja / app.js
Created December 17, 2017 18:46
angularjs $http example with factory
var app = angular.module('plunker', []);
app.factory('myService', function($http) {
return {
async: function() {
return $http.get('test.json'); //1. this returns promise
}
};
});
@Kamilnaja
Kamilnaja / Observable.ts
Last active December 10, 2017 22:56
Observable in angular2
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
@Kamilnaja
Kamilnaja / Observer.ts
Created November 25, 2017 22:18
Observer pattern using ts
interface Subject {
registerObserver(o: Observer): void;
removeObserver(o: Observer): void;
notifyObservers(): void;
}
interface Observer {
update(temperature: number): void;
}
"scripts": {
"clean": "rimraf dist",
"build": "tsc",
"watch:build": "tsc --watch",
"watch:server": "nodemon './dist/index.js' --watch './dist'",
"start": "npm-run-all clean build --parallel watch:build watch:server --print-label"
},
@Kamilnaja
Kamilnaja / angular.js
Created November 1, 2017 21:44
angularJS multiple ctrls
angular.module('myModule', []);
angular.module('myModule').controller('ControllerOne', ['$scope', function($scope) {
}]);
angular.module('myModule').controller('ControllerTwo', ['$scope', function ($scope) {
}])
@Kamilnaja
Kamilnaja / child.js
Created September 23, 2017 19:08
send function from one component react
<button onClick={this.props.greet}>Greet</button>
var MenuExample = React.createClass({
getInitialState: function () {
return {focused: 0};
},
clicked: function (index){
this.setState({focused: index})
},
var TimerExample = React.createClass({
getInitialState: function () {
return {elapsed: 0}
},
componentDidMount: function () {
this.timer = setInterval(this.tick, 50);
},
class Child extends React.Component {
render () {
return (<div>I'm the child</div>);
}
}
class ShowHide extends React.Component {
constructor () {
super ();
this.state = {