Skip to content

Instantly share code, notes, and snippets.

Avatar

Rob Wormald robwormald

View GitHub Profile
View component-using-service.js
ngOnInit() {
this.example = this.route.params
.switchMap(params => this.exampleService.getExample(params.id));
}
View ProductListComponent.js
class AppComponentController {}
export const AppComponent {
bindings: {
products: '=',
sort: '&'
},
controller: AppComponentController
}
View ng2.dev.tweak.js
"format register";
System.register("angular2/src/facade/lang", [], true, function(require, exports, module) {
var global = System.global,
__define = global.define;
global.define = undefined;
var __extends = (this && this.__extends) || function(d, b) {
for (var p in b)
if (b.hasOwnProperty(p))
d[p] = b[p];
function __() {
View Rx.js
"format register";
System.register("rxjs/util/noop", [], true, function(require, exports, module) {
var global = System.global,
__define = global.define;
global.define = undefined;
function noop() {}
exports.noop = noop;
global.define = __define;
return module.exports;
});
View test.js
var a = [{q : 2}, {q : 3}];
var qs = a.map(function(obj){ return obj.q });
//how will i use a 'for' loop to return a new array like that will look like this [2, 3] ?
View snippet.js
function processVertex(parent, vertices, children) {
var vertex = null, vertexChildren = null;
if (children && angular.isArray(children)) {
_.each(children, function(id) {
// find child in old data model by vertex id
vertex = _.find(vertices, { vertexId: id });
if (vertex) {
View decorators.js
import * as di from './annotations';
const Inject = (...dependencies) => {
return (classDef) => {
di.annotate.apply(di, [classDef].concat(dependencies.map((dep) => new di.Inject(dep))));
}
}
const Provide = (targetClassDef) => {
return (classDef) => {
View t.js
//returns array of users
function getUser(){
return fetch('user.json');
}
function getAccountsForUser(user){
return fetch(`users/${user.id}/accounts`);
}
function getPropertiesForAccount(account){
View JWT.js
(function(){
app.factory('JWT', JWT);
function JWT($window, $q){
var store = $window.localStorage;
var key = 'AXC_API_Storage.Token';
var service = {
getToken: getToken,
View ctrl.js
SomeService.placeSearch(options).then(function(results){
res.json(results);
})