1 | {
|
2 | "Angular Component": {
|
3 | "prefix": "ng2-component",
|
4 | "description": "Angular 2 component snippet",
|
5 | "body": [
|
6 | "import { Component, OnInit } from '@angular/core';",
|
7 | "",
|
8 | "@Component({",
|
9 | "\tmoduleId: module.id,",
|
10 | "\tselector: '${selector}',",
|
11 | "\ttemplateUrl: '${feature}.component.html'",
|
12 | "})",
|
13 | "export class ${Feature}Component implements OnInit {",
|
14 | "\tconstructor() { }",
|
15 | "",
|
16 | "\tngOnInit() { }$0",
|
17 | "}"
|
18 | ]
|
19 | },
|
20 | "Angular Service": {
|
21 | "prefix": "ng2-service",
|
22 | "description": "Angular 2 service snippet",
|
23 | "body": [
|
24 | "import { Injectable } from '@angular/core';",
|
25 | "",
|
26 | "@Injectable()",
|
27 | "export class ${ServiceName}Service {",
|
28 | "$0",
|
29 | "\tconstructor() { }",
|
30 | "}"
|
31 | ]
|
32 | },
|
33 | "Angular Pipe": {
|
34 | "prefix": "ng2-pipe",
|
35 | "description": "Angular 2 pipe snippet",
|
36 | "body": [
|
37 | "import { Pipe, PipeTransform } from '@angular/core';",
|
38 | "",
|
39 | "@Pipe({",
|
40 | "\tname: '${name}'",
|
41 | "})",
|
42 | "",
|
43 | "export class ${PipeName}Pipe implements PipeTransform {",
|
44 | "\ttransform(value: any, args: any[]): any {",
|
45 | "\t\t$0",
|
46 | "\t}",
|
47 | "}"
|
48 | ]
|
49 | },
|
50 | "Angular Routes": {
|
51 | "prefix": "ng2-routing",
|
52 | "description": "Angular 2 routing file snippet",
|
53 | "body": [
|
54 | "import { NgModule } from '@angular/core';",
|
55 | "import { Routes, RouterModule } from '@angular/router';",
|
56 | "",
|
57 | "import { ${Name}Component } from './${name}.component';",
|
58 | "",
|
59 | "const routes: Routes = [",
|
60 | " { path: '${path}', component: ${Name}Component },",
|
61 | "];",
|
62 | "",
|
63 | "@NgModule({",
|
64 | " imports: [RouterModule.for${Child|Root}(routes)],",
|
65 | " exports: [RouterModule],",
|
66 | "})",
|
67 | "export class ${Name}RoutingModule { }",
|
68 | "",
|
69 | "export const routedComponents = [${Name}Component];"
|
70 | ]
|
71 | },
|
72 | "Http.get": {
|
73 | "prefix": "ng2-http-get",
|
74 | "description": "Angular 2 Http.get snippet",
|
75 | "body": [
|
76 | "return this.http.get('${url}')",
|
77 | "\t.map((response: Response) => response.json()${0});"
|
78 | ]
|
79 | },
|
80 | "Subscribe": {
|
81 | "prefix": "ng2-subscribe",
|
82 | "description": "Angular 2 observable subscribe snippet",
|
83 | "body": [
|
84 | "this.${service}.${function}",
|
85 | "\t.subscribe(${arg} => this.${property} = ${arg});",
|
86 | "$0"
|
87 | ]
|
88 | },
|
89 | "Angular Bootstrapping": {
|
90 | "prefix": "ng2-bootstrap",
|
91 | "description": "Angular 2 bootstrap snippet",
|
92 | "body": [
|
93 | "import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';",
|
94 | "",
|
95 | "import { ${App}Module } from './${app}.module';",
|
96 | "",
|
97 | "platformBrowserDynamic().bootstrapModule(${App}Module)",
|
98 | "\t.then(success => console.log(`Bootstrap success`))",
|
99 | "\t.catch(error => console.log(error));",
|
100 | "$0"
|
101 | ]
|
102 | },
|
103 | "Angular Root Component": {
|
104 | "prefix": "ng2-component-root",
|
105 | "description": "Angular 2 App root component snippet",
|
106 | "body": [
|
107 | "import { Component } from '@angular/core';",
|
108 | "",
|
109 | "@Component({",
|
110 | "\tmoduleId: module.id,",
|
111 | "\tselector: '${my-app}',",
|
112 | "\ttemplate: `",
|
113 | "\t\t<router-outlet></router-outlet>",
|
114 | "\t\t`",
|
115 | "})",
|
116 | "export class ${App}Component { }",
|
117 | "$0"
|
118 | ]
|
119 | },
|
120 | "Angular Root Module": {
|
121 | "prefix": "ng2-module-root",
|
122 | "description": "Angular 2 Root Module snippet",
|
123 | "body": [
|
124 | "import { NgModule } from '@angular/core';",
|
125 | "import { BrowserModule } from '@angular/platform-browser';",
|
126 | "import { HttpModule } from '@angular/http';",
|
127 | "",
|
128 | "import { ${App}Component } from './${app}.component';",
|
129 | "import { AppRoutingModule } from './${app}.routing'; //TODO: Create ${app}.routing",
|
130 | "",
|
131 | "@NgModule({",
|
132 | "\timports: [",
|
133 | "\t\tBrowserModule,",
|
134 | "\t\tHttpModule,",
|
135 | "\t",
|
136 | "\t\tAppRoutingModule,",
|
137 | "\t],",
|
138 | "\tdeclarations: [${App}Component],",
|
139 | "\tproviders: [/* TODO: Providers go here */],",
|
140 | "\tbootstrap: [${App}Component],",
|
141 | "})",
|
142 | "export class ${App}Module { }",
|
143 | "$0"
|
144 | ]
|
145 | },
|
146 | "Angular Module": {
|
147 | "prefix": "ng2-module",
|
148 | "description": "Angular 2 Module snippet",
|
149 | "body": [
|
150 | "import { NgModule } from '@angular/core';",
|
151 | "",
|
152 | "import { ${Name}Component } from './${name}.component';",
|
153 | "",
|
154 | "@NgModule({",
|
155 | "\timports: [],",
|
156 | "\texports: [],",
|
157 | "\tdeclarations: [${Name}Component],",
|
158 | "\tproviders: [],",
|
159 | "})",
|
160 | "export class ${Name}Module { }",
|
161 | "$0"
|
162 | ]
|
163 | }
|
164 | } |
\ | No newline at end of file |