Skip to content

Instantly share code, notes, and snippets.

View pjlamb12's full-sized avatar
🏠
Working from home

Preston Lamb pjlamb12

🏠
Working from home
View GitHub Profile
@pjlamb12
pjlamb12 / page.html
Last active October 12, 2015 20:06
ng-class Issue
<ul class="search-results" ng-show="searchKeyword != '' && inputIsFocused">
<li ng-repeat="provider in providerList | searchFilter:searchFilterType:searchKeyword" ng-class="{'highlighted': provider == arrowSelectedItem}" ng-click="setSearchKeyword(provider)">{{provider.name}}</li>
</ul>
@pjlamb12
pjlamb12 / child.component.ts
Last active July 18, 2016 06:19
The child component's output event is called if you call the component's onTestOutputButtonClick() function directly, but if you try and emit an event from inside the service's callback, no event is emitted.
//Component Declaration
export class ChildComponent {
@Output() onOutputEvt: EventEmitter<any> = new EventEmitter<any>();
onTestOutputButtonClick() {
this.onOutputEvt.emit({data: 'Emitted data'});
}
makeAnUpdate(form) {
this._service.makeDbCall(data).subscribe(result => {
@pjlamb12
pjlamb12 / model.js
Created May 20, 2016 22:38
Sails.js Waterline Update Example
function update(args, done) {
Model.update([{id: args.id}, {id2: args.id2}], [{field1: args.field1}, {field2: args.field2}]).exec(function(err, updatedModel) {
console.log('error on update: ', err);
console.log('updated model: ', updatedModel);
return updatedModel;
});
}
@pjlamb12
pjlamb12 / session.ts
Created April 26, 2016 15:40
NgZone After Auth0 Login
import {Injectable, NgZone} from 'angular2/core';
import {Http, Response, Headers} from 'angular2/http';
import {Router} from 'angular2/router';
import {tokenNotExpired} from 'angular2-jwt';
import 'rxjs/add/operator/map';
import {AppConfig} from '../services/config';
declare var Auth0Lock: any;

Keybase proof

I hereby claim:

  • I am pjlamb12 on github.
  • I am pjlamb12 (https://keybase.io/pjlamb12) on keybase.
  • I have a public key ASDSwRAtv2HhIo1JyOuZe-QXS4G-9dxyH0bhwZANe0vhYwo

To claim this, I am signing this object:

@pjlamb12
pjlamb12 / buildCE.sh
Created March 5, 2019 16:35
Angular Elements Build script
ng build --prod --output-hashing=none && cat dist/ng-elements/runtime.js dist/ng-elements/polyfills.js dist/ng-elements/scripts.js dist/ng-elements/main.js > ../demo/ngelements.js

The next Angular item we’ll test is a component. This is going to be very similar to the directive we just tested. But, even though it’ll look almost the exact same, I think it’ll be worth going through the exercise of testing the component.

This component’s purpose is to display a list of alerts that we want to show to our users. There is a related service that adds and removes the alerts and passes them along using a Subject. It is slightly complicated because we’re going to use a TemplateRef to pass in the template that the ngFor loop should use for the alerts. That way the implementing application can determine what the alerts should look like. Here’s the component:

@Component({
	selector: 'alerts-display',
	template: '<ng-template ngFor let-alert [ngForOf]="alerts$ | async" [ngForTemplate]="alertTemplate"></ng-template>',
	styleUrls: ['./alerts-display.component.scss'],
})
@pjlamb12
pjlamb12 / book-list.js
Created August 29, 2019 19:17
Book/Rating List for Blake
const bookList = [['Book 1', 'some Author'], ['Book 2', 'some Author'], ['Book 3', 'some Author']];
const ratingList = [[0, 3, 5], [3, 0, 5]];
const nameList = ['Preston', 'Blake'];
function getRatings() {
let personIndex = 0;
const returnObj = {};
while (personIndex < nameList.length) {
@pjlamb12
pjlamb12 / compodoc.js
Last active September 14, 2020 12:42
Generate Compodoc Documentation for each App and Library in an Nx workspace from a script
const angularJson = require('./angular.json');
const exec = require('child_process').exec;
const fs = require('fs');
const mainProjects = Object.keys(angularJson.projects).filter(proj => !proj.includes('e2e'));
const tsConfigPaths = parseTsconfigPaths();
function parseTsconfigPaths() {
const pathsArray = [];
for (const projectName of mainProjects) {
pdf_book:
pandoc_args: --listings
includes:
in_header: preamble.tex