angular.module('foo', []).directive('btnGroup'['$parse', function($parse) {
return {
restrict : 'E',
replace : true,
scope : true,
template : '',
link : function(scope, elem, attrs) {
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface PizzaContext { | |
toppings?: string[]; | |
size?: string; | |
} | |
export class DefaultPizzaContext implements PizzaContext { | |
toppings: string[]; | |
size: string; | |
constructor(form: PizzaContext = null) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Component} from '@angular/core'; | |
@Component({ | |
selector: 'app-my-chart', | |
template: ` <div> | |
<canvas baseChart [datasets]="chartData" [labels]="chartLabels" [options]="chartOptions" [legend]="chartLegend" | |
[chartType]="chartType"></canvas> | |
</div>` | |
}) | |
export class MyChartComponent { | |
public chartOptions: any = { |
I am mocking a ViewContainerRef for a jasmine test.
The code to be testes does at one point this: viewRef.element.nativeElement.scrollTop = 5
So I wrote a ViewContainerRefMock
export class ViewContainerRefMock extends ViewContainerRef {
constructor() {
super();
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* Run the following code with `ng test` | |
* Is this a jasmine, typescript, angular or stupid developer bug? | |
**/ | |
import { | |
ComponentFactory, | |
ComponentRef, | |
ElementRef, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'existing-element', | |
template: `hello World` | |
}) | |
export class ExistingElementComponent { | |
} | |
@Component({ | |
selector: 'root', | |
template: ` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Component} from '@angular/core'; | |
export function sayHi() { | |
return 'Hi'; | |
} | |
export function echo(msg) { | |
return 'Echo:' + msg; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class RouteChange implements Action { | |
readonly type = '[Router] Route Change'; | |
constructor(public payload: { params: any, path: string, queryParams: any }) {} | |
} | |
const parseActivatedRouteToUriArray = (routeSnapshot: ActivatedRouteSnapshot): string[] => { | |
let uri = []; | |
if (!isUndefinedOrNull(routeSnapshot) && !isUndefinedOrNull(routeSnapshot.routeConfig)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const viewPort = document.createElement('meta'); | |
viewPort.setAttribute('name', 'viewport'); | |
viewPort.setAttribute('content', 'width=device-width, initial-scale=1'); | |
document.getElementsByTagName('head')[0].appendChild(viewPort); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const onInit = <T extends Constructor>(base: T = class {} as T) => | |
class OnInitSubject extends base implements OnInit, AfterViewInit { | |
private _init = new BehaviorSubject<void>(null); | |
onInit$ = this._init.asObservable(); | |
ngOnInit(): void { | |
this._init.next(); | |
// tslint:disable-next-line:no-unused-expression | |
super['ngOnInit'] && super['ngOnInit'](); |
OlderNewer