Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

evo(angular): Add angular snippets for signals and control flow syntax #545

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions snippets/frameworks/angular/html.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,26 @@
"body": ["*ngFor=\"let ${1:item} of ${2:stream} | async as ${3:list}\"${0}"],
"description": "Angular *ngForAsync"
},
"ngForNext": {
"prefix": "a-ngForNext",
"body": [
"@for (${1:item} of ${2:items}; track ${3:trackBy}) {",
"\t${0:forBlock}",
"}"
],
"description": "Angular new control flow syntax ngFor"
},
"ngForEmptyNext": {
"prefix": "a-ngForEmptyNext",
"body": [
"@for (${1:item} of ${2:items}; track ${3:trackBy}) {",
"\t${4:forBlock}",
"} @empty {",
"\t${0:emptyBlock}",
"}"
],
"description": "Angular new control flow syntax ngFor with empty block"
},
"ngForm": {
"prefix": "a-form",
"body": ["<form (ngSubmit)=\"onSubmit()\" #${1:form}=\"ngForm\">", "</form>"],
Expand Down Expand Up @@ -69,6 +89,26 @@
"body": ["*ngIf=\"${1:expression};else ${2:templateName}\""],
"description": "Angular *ngIfElse"
},
"ngIfNext": {
"prefix": "a-ngIfNext",\
"body": [
"@if (${1:expression}) {",
"\t${0:ifBlock}",
"}"
],
"description": "Angular new control flow syntax for ngIf"
},
"ngIfElseNext": {
"prefix": "a-ngIfElseNext",\
"body": [
"@if (${1:expression}) {",
"\t${2:ifBlock}",
"} @else {",
"\t${0:elseBlock}",
"}"
],
"description": "Angular new control flow syntax for ngIf"
},
"ngModel": {
"prefix": "a-ngModel",
"body": ["[(ngModel)]=\"${1:binding}\""],
Expand Down Expand Up @@ -111,6 +151,20 @@
],
"description": "Angular ngSwitch"
},
"ngSwitchNew": {
"prefix": "a-ngSwitchNext",
"body": [
"@switch (${1:expression}) {",
"\t@case (${2:case}) {",
"\t\t${3:caseBlock}",
"\t}${0}",
"\t@default {",
"\t\t${4:defaultBlock}",
"\t}",
"}"
],
"description": "Angular new control flow syntax for ngSwitch"
},
"pre w/ json": {
"prefix": "a-prej",
"body": ["<pre>{{${1:model} | json}}</pre>$0"],
Expand Down
10 changes: 10 additions & 0 deletions snippets/frameworks/angular/typescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -616,5 +616,15 @@
"prefix": "a-trackby",
"description": "TrackBy Function",
"body": ["${1:trackBy}(index: number, ${2:name}: ${3:model}): ${4:number} {", " return ${2:name}${5:.id};$0", "}"]
},
"Angular Writable Signal": {
"prefix": "a-signal",
"body": ["${1:variable}: WritableSignal<${2:T}> = signal(${3:defaultValue});${0}"],
"description": "Angular Writable Signal"
},
"Angular Computed Signal": {
"prefix": "a-computedSignal",
"body": ["${1:variable}: Signal<${2:T}> = computed(() => ${3:expression});${0}"],
"description": "Angular Writable Signal"
}
}