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
#!/usr/bin/env bash | |
# Like this script? | |
# Generate boilerplate for similar ones at https://bashplate.wolfgang-werner.net. | |
set -o errexit # exit on error | |
set -o nounset # don't allow unset variables | |
# set -o xtrace # enable for debugging | |
usage() { | |
printf "Script Description\n" |
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
// Create a new instance | |
let myWebComponent = document.createElement('my-element'); | |
// Append it to body | |
document.body.appendChild(myWebComponent); |
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
<html> | |
<head> | |
<title>My Element</title> | |
</head> | |
<body> | |
// Prints: Hello, I'm a web component | |
<my-element></my-element> | |
<script src="my-element.js"></script> | |
</body> |
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
class MyElement extends HTMLElement { | |
constructor() { | |
super(); | |
// We create a shadowDOM | |
this.attachShadow({mode: 'open'}); | |
// Then we inject a html template into the created ShadowDOM | |
this.shadowRoot.innerHTML = ` | |
Hello, I'm a web component | |
`; | |
} |
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 data = { | |
title: 'hello world', | |
endTime: 123456, | |
foo: [1, 2, 3] | |
}; | |
const properties = { | |
title: 'string', | |
endTime: 'number', | |
foo: 'array' |
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
<div> | |
<form [formGroup]="articleFormService.articleFormModel.form" novalidate (ngSubmit)="create()"> | |
<label> | |
Title | |
<input type="text" formControlName="title" placeholder="Title"> | |
<span class="error" *ngIf="articleFormService?.articleFormModel?.form.get('title').touched && !articleFormService?.articleFormModel?.form.get('title').valid"> | |
A title is required | |
</span> | |
</label> | |
<label> |
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
// app.component.ts | |
import {Component} from '@angular/core' | |
import {ArticleFormService} from 'src/models/app-forms/article-form/article-form.service.ts' | |
@Component({ | |
selector: 'my-app', | |
templateUrl: 'src/app.component.html' | |
}) | |
export class AppComponent { |
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
// app.module.ts | |
import {NgModule} from '@angular/core' | |
import {BrowserModule} from '@angular/platform-browser' | |
import {FormsModule, ReactiveFormsModule} from '@angular/forms' | |
import {ArticleFormModule} from 'src/models/app-forms/article-form/article-form.module.ts' | |
import {AppComponent} from 'src/app.component.ts' | |
@NgModule({ |
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
// article-form.module.ts | |
import {NgModule} from '@angular/core'; | |
import {CommonModule} from "@angular/common"; | |
import {ArticleFormBackend} from "./article-form.backend"; | |
import {ArticleFormService} from "./article-form.service"; | |
@NgModule({ | |
imports: [ | |
CommonModule |
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
// article-form.service.ts | |
import {Injectable} from "@angular/core"; | |
import {AppFormsBase} from "../app-forms-base.class"; | |
import {ArticleFormBackend} from "./article-form.backend"; | |
import {ArticleFormModel} from "./article-form.model"; | |
import {IArticle} from "./article-form.interface"; | |
@Injectable() | |
export class ArticleFormService extends AppFormsBase { |
NewerOlder