Skip to content

Instantly share code, notes, and snippets.

View sarfarazansari's full-sized avatar

Sarfaraz Ansari sarfarazansari

View GitHub Profile
export class HomeService {
constructor($log, $window, $rootScope, $http, $resource) {
'ngInject';
this.$log = $log;
this.$http = $http;
this.$window = $window;
this.$rootScope = $rootScope;
@sarfarazansari
sarfarazansari / check 2d array is empty or undefined
Created February 22, 2017 04:47
check if 2 dimensional array is empty and undefined by using try catch
var arr1 = [
['A', 'B', 'C'],
['D', 'E', 'F']
];
var arr2 = [
['A', 'B', 'C'],
[]
];
@sarfarazansari
sarfarazansari / SimpleGithubUser.factory.js
Last active February 14, 2017 05:15
Factory example for ECMA+Angular
export function SimpleGithubUser ($http) {
'ngInject';
var apiUrl = 'https://api.github.com/';
// instantiate our initial object
var SimpleGithubUser = function(username) {
this.username = username;
this.profile = this.getProfile();
};
//assuming array look like this.
var arr = [
["Status", "Name", "Marks", "Position"],
["active", Sarfaraz, 10.0, "Front-end-dev"],
["active", John, 10.0, "Front-end-dev"],
["deactive", Raganar, 10.0, "UI designer"],
];
console.log (arrToObject(arr));