Skip to content

Instantly share code, notes, and snippets.

View molcik's full-sized avatar
👀
WIP

Filip Molcik molcik

👀
WIP
View GitHub Profile
<md-form-field>
<input mdInput [mdDatepicker]="picker" placeholder="Choose a date">
<md-datepicker-toggle mdSuffix [for]="picker"></md-datepicker-toggle>
<md-datepicker #picker></md-datepicker>
</md-form-field>
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
template: `
<nav>
<h2>Menu:</h2>
<a routerLink="classic">Classic component</a>
<a routerLink="lazy">Lazy loaded component</a>
</nav>
import { ModuleWithProviders, NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { ClassicComponent } from './classic.component';
@NgModule({
imports: [
RouterModule.forRoot([
{ path: '', redirectTo: 'classic', pathMatch: 'full' },
{ path: 'classic', component: ClassicComponent },
{ path: 'lazy', loadChildren: 'app/lazy/lazy.module#LazyModule' }
import { Component } from '@angular/core';
@Component({
template: '<p>Lazy Component</p>'
})
export class LazyComponent {}
import { ModuleWithProviders, NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { LazyComponent } from './lazy.component';
@NgModule({
imports: [
RouterModule.forChild([
{ path: '', component: LazyComponent }
], { useHash: true })
],
import { NgModule } from '@angular/core';
import { LazyComponent } from './lazy.component';
import { LazyRoutingModule } from './lazy.routing';
@NgModule({
imports: [LazyRoutingModule],
declarations: [LazyComponent]
})
export class LazyModule {}
@NgModule({
imports: [ BrowserModule ],
declarations: [ App, SafePipe ],
bootstrap: [ App ]
})
<iframe [src]="url | safe"></iframe>
@molcik
molcik / safe.pipe.ts
Last active September 25, 2017 14:08
import { Pipe, PipeTransform } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
@Pipe({
name: 'safe'
})
export class SafePipe implements PipeTransform {
constructor(private sanitizer: DomSanitizer) { }
transform(url) {
@molcik
molcik / app.ts
Created September 22, 2017 07:12
app.ts
import {Component, NgModule, VERSION} from '@angular/core'
import {Http} from '@angular/http'// DON'T FORGOT TO IMPORT HTTP
import {BrowserModule} from '@angular/platform-browser'
import {HttpModule} from '@angular/http'; // DON'T FORGOT TO IMPORT HTTPMODULE
@Component({
selector: 'my-app',
template:
`<div>
<h2>Response from server: {{greeting}}</h2>