This file contains hidden or 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
<form #myForm="ngForm" (ngSubmit)="onSubmit()"> | |
<div ngModelGroup="user"> | |
<label> | |
Name: | |
<input type="text" name="name" [(ngModel)]="name" required> | |
</label> | |
<div *ngIf="myForm.controls['user']?.controls['name'].invalid && myForm.controls['user']?.controls['name'].touched"> | |
<div *ngIf="myForm.controls['user']?.controls['name'].errors.required">Name is required</div> | |
</div> | |
</div> |
This file contains hidden or 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-form', | |
templateUrl: './form.component.html', | |
}) | |
export class FormComponent { | |
name: string; | |
onSubmit() { |
This file contains hidden or 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
<form #myForm="ngForm"> | |
<div ngModelGroup="user"> | |
<label> | |
Name: | |
<input type="text" name="name" [(ngModel)]="name" required> | |
</label> | |
<div *ngIf="myForm.controls['user']?.controls['name'].invalid && myForm.controls['user']?.controls['name'].touched"> | |
<div *ngIf="myForm.controls['user']?.controls['name'].errors.required">Name is required</div> | |
</div> | |
</div> |
This file contains hidden or 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
<form #myForm="ngForm"> | |
<label> | |
Name: | |
<input type="text" name="name" [(ngModel)]="name" required> | |
</label> | |
<button type="submit">Submit</button> | |
</form> |
This file contains hidden or 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
<form> | |
<label> | |
Name: | |
<input type="text" name="name" required> | |
</label> | |
<button type="submit">Submit</button> | |
</form> |
This file contains hidden or 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
// create a binary search function that takes in a non-sorted array and a target value | |
const binarySearch = (arr: number[], target: number) => { | |
// sort the array | |
arr.sort((a, b) => a - b); | |
// create a left and right pointer | |
let left = 0; | |
let right = arr.length - 1; | |
// loop while left is less than or equal to right |
This file contains hidden or 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 { Store } from '@ngxs/store'; | |
import { AppModule } from 'src/app/app.module'; | |
import { AnalyticsActions } from 'src/app/state/analytics/analytics.actions'; | |
import { isFunction } from 'util'; | |
import { captureBreadcrumb } from '../utils'; | |
/** | |
* ***************************** WARNING ********************************** | |
* To use this decorator you must ensure that your component implements * | |
* both OnInit and OnDestroy. If it does not this will not work. * |
This file contains hidden or 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 { NgModule } from '@angular/core'; | |
import { Routes, RouterModule } from '@angular/router'; | |
import { MainComponent } from './main/main.module'; | |
const routes: Routes = [ | |
{ path: '', redirectTo: '/main', pathMatch: 'full' }, | |
{ | |
path: 'main', | |
component: MainComponent | |
}, |
This file contains hidden or 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
<script> | |
import Thing from './Thing.svelte'; | |
let user = { loggedIn: false }; | |
let things = [ | |
{ id: 1, name: 'apple' }, | |
{ id: 2, name: 'banana' }, | |
{ id: 3, name: 'carrot' }, | |
{ id: 4, name: 'doughnut' }, | |
{ id: 5, name: 'egg' }, |
This file contains hidden or 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 { NgModule } from '@angular/core'; | |
import { RouterModule, Routes } from '@angular/router'; | |
import { LandingRouteComponent } from './landing-route.component'; | |
/** | |
* Since this route is lazy loaded in the app-routing.module.ts we will declare a blank | |
* path here and give it the component we wish to load at the current route. | |
*/ | |
const routes: Routes = [{ path: '', component: LandingRouteComponent, children: [ | |
{ path: 'variation1', loadChildren: () => import('./variation-1/variation-1.module.ts').then((mod) => mod.Variation1Module) } |
NewerOlder