Skip to content

Instantly share code, notes, and snippets.

View Prasanna-Poonacha's full-sized avatar

Prasanna Poonacha Prasanna-Poonacha

View GitHub Profile
@Prasanna-Poonacha
Prasanna-Poonacha / Service-and-Factory-in-Angular.markdown
Created February 25, 2015 18:46
Service and Factory in Angular

Service and Factory in Angular

Factories offer slightly more flexibility than services because they can return functions which can then be new'd. This follows the factory pattern from object oriented programming. A factory can be an object for creating other objects.

A Pen by Prasanna Poonacha on CodePen.

License.

@Prasanna-Poonacha
Prasanna-Poonacha / app.js
Last active November 2, 2020 11:14
Create a table
/**
* getColumnsHeader only returns columns that user is wanting to see
*/
function getColumnsHeader() {
// async request
return new Promise((resolve, reject) => {
setTimeout(() => {
const headers = [
{
key: 'name.first',
class App extends Component {
state = {
users: [],
repos: [],
loading: false,
alert: null,
user: {},
};
searchUsers = async (text) => {
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Interview</title>
</head>
<body>
<script>
const posts = [
@Prasanna-Poonacha
Prasanna-Poonacha / app.js
Last active November 2, 2020 11:17
HTTP
function easyHttp() {
this.http = new XMLHttpRequest();
}
easyHttp.prototype.get = function (url, cb) {
let self = this;
self.http.open('GET', url, true);
self.http.onload = function () {