Skip to content

Instantly share code, notes, and snippets.

@jimthedev
Created September 23, 2015 05:16
Show Gist options
  • Select an option

  • Save jimthedev/29ac38a7734d64838e79 to your computer and use it in GitHub Desktop.

Select an option

Save jimthedev/29ac38a7734d64838e79 to your computer and use it in GitHub Desktop.

Revisions

  1. jimthedev created this gist Sep 23, 2015.
    68 changes: 68 additions & 0 deletions typescript.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,68 @@
    {
    "New NG2 Component (Item)": {
    "prefix": "ng2c",
    "body": [
    "import {Component, View, CORE_DIRECTIVES, FORM_DIRECTIVES} from 'angular2/angular2';",
    "// import {ExampleListComponent} from '../example/example-list.component';",
    "",
    "@Component({",
    " selector: '${1:dashed-name}',",
    " properties: ['id']",
    "})",
    "@View({",
    " directives: [ CORE_DIRECTIVES, FORM_DIRECTIVES/*, ExampleListComponent*/],",
    " styles: [`",
    " ${1:dashed-name}-contents { }",
    " `],",
    " template: `",
    " <${1:dashed-name}-contents>",
    " <id>${1:dashed-name} {{id}}</id>:",
    " <!-- <example-list></example-list> -->",
    " </${1:dashed-name}-contents>",
    " `",
    "})",
    "export class ${2:CapitalCaseName}Component {",
    " constructor(${3:public serviceInjections:ServiceInjections}) {",
    " ${4://Press ESC to finish or Tab to start over}",
    " }",
    " onInit() {",
    " }",
    "}"
    ],
    "description": "Create a new Angular2 single item component in this file."
    },
    "New NG2 Directive": {
    "prefix": "ng2d",
    "body": [
    "import {Directive, ElementRef} from 'angular2/angular2';",
    "",
    "@Directive({",
    " selector: '[${1:selector}]' // using [ ] means selecting attributes",
    "})",
    "export class ${2:}Directive {",
    " constructor(element: ElementRef) {",
    " // simple DOM manipulation to set font size to x-large",
    " // `nativeElement` is the direct reference to the DOM element",
    " element.nativeElement.fontSize = 'x-large';$3",
    " }",
    "}"
    ],
    "description": "Create a new Angular2 directive in this file."
    },
    "New Import": {
    "prefix": "imp",
    "body": [
    "import {${1}} from '${2:moduleOrPath}';",
    "${3}"
    ],
    "description": "Import a module."
    },
    "Import Standard Component": {
    "prefix": "impc",
    "body": [
    "import {${1:CapitalCase}Component} from '../${2:dash-case}/${2:dash-case}.component';",
    "${3}"
    ],
    "description": "Import a module."
    }
    }