Skip to content

Instantly share code, notes, and snippets.

View Armenvardanyan95's full-sized avatar

Armen Vardanyan Armenvardanyan95

View GitHub Profile
type ModelTypes = 'product' | 'order';
type Product = {productName: string};
type Order = {orderId: number};
type Model = {
id: number;
type: ModelTypes;
entity: Product | Order;
}
@Injectable()
export class SomeService {
data = 10;
updateData() {
this.data = 20;
}
}
@Component({
@Injectable()
export class SomeService {
data = 10;
updateData() {
this.data = 20;
}
}
@Component({
// imagine we have a huge component that is highly customizable
// we could add a lot of inputs as options to it
<app-editor
[undoRedo]="true"
[copyPaste]="true"
[textFormatting]="true"/>
// or, we could use the power of content projection
// to both ensure design consistency and higher reusability
@Injectable()
export class DataService {
// here the name is getData
getData() {}
}
@Injectable()
export class SomeDataService {
// here the name is getSomeOtherData
getSomeOtherData() {}
@Component({
template: `
<h2>User List:</h2>
<table>
<thead>
<tr>
<th>Username</th>
<th>Email</th>
<th>Last Login</th>
<th>Role</th>
// instead of this
@Component({
template: `
@switch (country.value()) {
@case ('UK') {
<app-uk-payroll/>
}
@case ('USA') {
<app-usa-payroll/>
}
@Component({
template: `
<div>
<label for="continent">Continent:</label>
<select id="continent" [(ngModel)]="selectedContinent">
@for(continent of continents; track continent) {
<option [value]="continent">{{ continent }}</option>
}
</select>
</div>
const fs = require('fs');
const path = require('path');
async function findMissingImports(projectRoot, directiveName, directiveClass) {
const missingImportFiles = [];
const searchDirectory = async (dir) => {
const files = fs.readdirSync(dir);
for (const file of files) {
@import "src/scss/redesign/base/variables.scss";
@import "src/scss/redesign/base/mixins.scss";
:host {
.employee-grid-view {
.row {
margin-left: -6px !important;
margin-right: -6px !important;
[class*='col-sm'] {
padding-left: 6px !important;