Skip to content

Instantly share code, notes, and snippets.

View KylerJohnson26's full-sized avatar

Kyler Johnson KylerJohnson26

View GitHub Profile
@KylerJohnson26
KylerJohnson26 / dropdown.directive.ts
Last active March 4, 2019 00:39
Attribute directive with HostBinding - Attribute directive article
import { Directive, HostBinding, HostListener } from '@angular/core';
@Directive({
selector: '[appDropdown]'
})
export class DropdownDirective {
constructor() {}
@HostBinding('class.open') isOpen = false;
@KylerJohnson26
KylerJohnson26 / dropdown.directive.ts
Created March 3, 2019 22:55
Attribute Directive Renderer2 - Attribute directive article
import { Directive, HostListener, ElementRef, Renderer2 } from '@angular/core';
@Directive({
selector: '[appDropdown]'
})
export class DropdownDirective {
constructor(
private elRef: ElementRef,
private renderer: Renderer2
@KylerJohnson26
KylerJohnson26 / dropdown.directive.ts
Created March 3, 2019 17:18
Attribute directive using ElementRef - Attribute directive article
import { Directive, ElementRef, HostListener } from '@angular/core';
@Directive({
selector: '[appDropdown]'
})
export class DropdownDirective {
constructor(
private elRef: ElementRef
) { }
@KylerJohnson26
KylerJohnson26 / app.component.css
Last active March 3, 2019 16:51
Attribute Directive CSS - Attribute Directive article
.dropdown-btn {
background: #0288D1;
border: 1px solid #0288D1;
border-radius: .25em;
color: white;
cursor: pointer;
font-size: 1.5em;
outline: 0;
}
@KylerJohnson26
KylerJohnson26 / app.component.html
Created March 3, 2019 16:37
Attribute directive HTML - Attribute Directive article
<div class="wrapper">
<button appDropdown class="dropdown-btn" type="button">Menu</button>
<div class="dropdown">
<a href="https://medium.com/@kylerjohnson26" class="dropdown-item">Find me on Medium</a>
<a href="https://twitter.com/KylerJohnson26" class="dropdown-item">Find me on Twitter</a>
<a href="https://github.com/KylerJohnson26" class="dropdown-item">Find me on Github</a>
</div>
@KylerJohnson26
KylerJohnson26 / dropdown.directive.ts
Last active March 3, 2019 14:14
@directive decorator - Attribute directive article
@Directive({
selector: '[appDropdown]'
})
export default class Dropdown { }
@KylerJohnson26
KylerJohnson26 / profile-routing.module.ts
Created February 10, 2019 16:33
From ng-lazy-loading-demo for lazy loading blog
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { ProfileComponent } from './profile/profile.component';
const routes: Routes = [
{ path: '', component: ProfileComponent }
];
@NgModule({
imports: [RouterModule.forChild(routes)],
@KylerJohnson26
KylerJohnson26 / app-routing.module.ts
Last active November 14, 2019 01:17
From ng-lazy-loading-demo for lazy loading blog
{
path: 'profile',
loadChildren: () => import('./profile/profile.module').then(m => m.ProfileModule)
},
@KylerJohnson26
KylerJohnson26 / app-routing.module.ts
Last active November 14, 2019 01:14
From ng-lazy-loading-demo for lazy loading blog
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from './core/home/home.component';
const routes: Routes = [
{
path: 'profile',
loadChildren: () => import('./profile/profile.module').then(m => m.ProfileModule)
},
{
@KylerJohnson26
KylerJohnson26 / app.module.ts
Created February 10, 2019 15:10
From ng-demo-lazy-loading for lazy loading blog
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { CoreModule } from './core/core.module';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
@NgModule({
declarations: [