[转]VS Code 扩展 Angular 6 Snippets - TypeScript, Html, Angular Material, ngRx, RxJS & Flex Layout...

本文转自:https://marketplace.visualstudio.com/items?itemName=Mikael.Angular-BeastCode

Visual Studio Code TypeScript and Html snippets and code examples for Angular 2,4,5 & 6.

All code snippets are based on and follow the Angular style guide https://angular.io/docs/ts/latest/guide/style-guide.html

PrefixDescription
ng-Angular Snippets
fx-Angular Flex Layout Snippets
ngrx-Angular NgRx Snippets
ngxs-Angular Ngxs Snippets
m-Angular Material Design Snippets
rx-RxJS Snippets for both TypeScript and JavaScript
sw-Service Workers Snippets
t-Test Snippets
e-Test Expect Snippets
pwa-Progressive Web Applications Snippets
PostfixDescription
-cheatsheetCheat Sheet

This extension is optimized for developers that use Angular and are no longer using AngularJS (Angular 1). If you type in AngularJS keywords, it will suggest an Angular solutions. This is by design and meant to help developers learn how AngularJS concepts and techniques map to Angular.

See example below for ng-repeat and ng-click:

ngRepeatSnippet

All Angular snippets starts with "ng-". Multiple snippets come in multiple variations. For instance when you want to create a new component you can choose between having the template and css inline or not:

  • ng-component
  • ng-component-inline

ngComponentSnippet

ng-for currently has even more variations, so make sure you pick the one you want before you press enter:

  • ng-for
  • ng-for-index
  • ng-for-li
  • ng-for-trackBy

ngForSnippet

All Material snippets starts with "m-" and there are now over 50 Material snippets in this package.

You don't need to type any dashes: "ngrxr" -> "ng-rx-reducer" snippet

SnippetDescription
cli-cheatsheetCli Cheat Sheet
e-atbrExpectAsync toBeResolved
e-ntbExpect Not toBe
e-ntbdExpect not toBe Defined
e-ntbfExpect not toBe Falsy
e-ntbnExpect Not toBeNull
e-ntbtExpect not toBe Truthy
e-ntbuExpect not toBe Undefined
e-nthbcExpect Not toHaveBeenCalled
e-ntmExpect Not toMatch
e-ntmrExpect Not toMatch regex
e-tbExpect toBe
e-tbctExpect toBeCloseTo
e-tbdExpect toBe Defined
e-tbfExpect toBe Falsy
e-tbgtExpect toBeGreaterThan
e-tbgtoeExpect toBeGreaterThanOrEqual
e-tbltExpect toBeLessThan
e-tbltoeExpect toBeLessThanOrEqual
e-tbnExpect toBeNull
e-tbtExpect toBe Truthy
e-tbuExpect toBe Undefined
e-thbcExpect toHaveBeenCalled
e-thbcwExpect toHaveBeenCalledWith
e-thrtExpect toHaveReturnedTimes(2)
e-tmExpect toMatch
e-tmrExpect toMatch regex
e-tmsJest Expect toMatchSnapshot
fx-colFlex Layout Column
fx-col-elementFlex Layout Column with Element
fx-col-reverseFlex Layout Reverse Column
fx-importFlex Layout Import
fx-itemFlex Layout Item
fx-item-alignFlex Layout Item with fxFlexAlign
fx-item-fillFlex Layout Item with fxFlexFill
fx-item-offsetFlex Layout Item with fxFlexOffset
fx-item-orderFlex Layout Item with fxFlexOrder
fx-layoutFlex Layout Property
fx-layout-alignFlex Layout Align Property
fx-layout-gapFlex Layout Gap Property
fx-rowFlex Layout Row
fx-row-reverseFlex Layout Reverse Row
m-buttonRectangular Material button w/ no elevation.
m-button-fabCircular button w/ elevation.
m-button-fab-miniSmall circular button w/ elevation.
m-button-iconCircular Material button with a transparent background
m-button-raisedRectangular Material button w/ elevation.
m-button-toggleMaterial toggle button
m-cardMaterial Basic Card
m-card-fullMaterial Card
m-checkboxMaterial Checkbox
m-checkbox-ngmodelMaterial Checkbox ngmodel
m-chipMaterial Chip
m-chip-listMaterial Chip List
m-chip-list-stackedMaterial Chip Stacked List
m-datepickerMaterial Datepicker
m-dividerMaterial Divider
m-divider-insetMaterial Inset Divider
m-divider-verticalMaterial Vertical Divider
m-expansion-panelMaterial Expansion Panel
m-grid-listMaterial Grid List
m-iconMaterial Icon
m-icon-badgeMaterial Icon with a Badge
m-icon-fontawesomeMaterial Font Awesome Icon
m-icon-svgMaterial SVG Icon
m-inputMaterial Input Textbox
m-listMaterial List
m-list-itemMaterial List Item
m-list-ngforMaterial List ngFor
m-paginatorMaterial Paginator
m-progress-barMaterial Determinate Progress Bar
m-progress-bar-bufferMaterial Buffer Progress Bar
m-progress-bar-indeterminateMaterial indeterminate Progress Bar
m-progress-bar-queryMaterial Query Progress Bar
m-radiobuttonMaterial Radio Button
m-radiobutton-optionMaterial Radio Button Option
m-selectMaterial Select
m-slide-toggleMaterial Slide toggle
m-sliderMaterial Slider
m-slider-thumbLabelMaterial Slider thumbLabel
m-slider-tickIntervalMaterial Slider tickInterval
m-slider-tickInterval-autoMaterial Slider tickInterval Auto
m-slider-verticalMaterial Vertical Slider
m-spinnerMaterial Determinate Spinner
m-spinner-indeterminateMaterial Indeterminate Spinner
m-stepMaterial Vertical Stepper
m-stepper-horizontalMaterial Horizontal Stepper
m-stepper-verticalMaterial Vertical Stepper
m-tabMaterial Tab
m-tab-groupMaterial Tab Group
m-tableMaterial Table
m-table-columnMaterial Table Column
m-toolbarMaterial toolbar
m-toolbar-multiRowMaterial Toolbar with multiple rows
m-toolbar-rowMaterial toolbar row
m-tooltipMaterial Tooltip
m-tooltip-positionMaterial Tooltip position
m-tooltip-with-positionMaterial Tooltip with position
ng-afterContentCheckedLifecycle hook: Called after every check of the component's or directive's content
ng-afterContentInitLifecycle hook: Called after ngOnInit when the component's or directive's content has been initialized
ng-afterViewCheckedLifecycle hook: Called after every check of the component's view. Applies to components only
ng-afterViewInitLifecycle hook: Called after ngAfterContentInit when the component's view has been initialized
ng-binding-onewayProperty: [property]="expression"
ng-binding-twowayTwo-way data binding with the NgModel
ng-bootstrapingBootstraping example
ng-buttonA button element with a click event
ng-button-submitA submit button element with a click event
ng-classCSS class
ng-clickClick event
ng-componentComponent with template and style urls
ng-component-inlineComponent with inline Template and Styles
ng-component-value-accessorAngular Component With NG_VALUE_ACCESSOR
ng-confThe World's Original Angular Conference
ng-controllerUse component instead.
ng-debugpre obj pipe json
ng-debug-asyncpre obj pipe async pipe json
ng-directiveDirective template
ng-directive-attributeAttribute directive
ng-directive-cssCSS directive
ng-doCheckLifecycle hook: Called every time that the input properties of a component or a directive are checked
ng-eventEvent: (event) = "onEvent()"
ng-filterFor performance reasons, no comparable pipe exists in Angular 2. Do all your filtering in the component. If you need the same filtering code in several templates, consider building a custom pipe.
ng-forFor-loop directive
ng-for-indexFor-loop directive with index
ng-for-liFor-loop directive with li element
ng-for-trackByFor-loop directive with trackBy
ng-girlsAngular Girls
ng-hideUsage: Bind to the hidden property.
ng-hrefUsage: Bind to the href property.
ng-http-getHttp observable get request
ng-http-get-postHttp observable get & post request
ng-http-interceptorIntercept an outgoing HttpRequest and optionally transform it or the response.
ng-httpClient-getHttpClient observable get request
ng-ifIf directive: *ngIf="expression"
ng-if-elsev4: If else directive: *ngIf="expression; else"
ng-if-then-elsev4: If then else directive: *ngIf="expression; then; else"
ng-importimport module or component from path;
ng-inputClass Input Property
ng-interpolationInterpolation: {{ interpolation }}
ng-material-moduleApp Material Module
ng-modelngModel directive: [(ngModel)]="name"
ng-moduleFeature Module
ng-module-rootApp root module
ng-ngOnChangesLifecycle hook: Called before any other lifecycle hook
ng-onDestroyLifecycle hook: Called before the instance is destroyed
ng-onInitLifecycle hook: Called after the constructor
ng-orderByFor performance reasons, no comparable pipe exists in Angular 2. Instead, use component code to order or sort results. If you need the same ordering or sorting code in several templates, consider building a custom pipe.
ng-outputClass Output Event
ng-pipePipe template
ng-pipe-asyncAsync pipe - Usage: observable_or_promise_expression | async
ng-pipe-currencyCurrency pipe - Usage: money | currency:'EUR'
ng-pipe-dateDate pipe - Default format: 09/15/1971
ng-pipe-date-customDate pipe - Format: "MM/dd/yy" = 09/15/71
ng-pipe-date-fullFull date pipe - Format: Wednesday, September 15, 1971
ng-pipe-date-shortShort date pipe - Format: 09/15/1971
ng-pipe-decimalDecimal pipe - Usage: number_expression | decimal[:digitInfo]
ng-pipe-exampleAngular pipe example
ng-pipe-jsonJson pipe - Usage: object | json
ng-pipe-lowercaseLowercase pipe
ng-pipe-percentPercent pipe - Usage: number_expression | percent[:digitInfo]
ng-pipe-sliceSlice pipe - Usage: array_or_string_expression | slice:start[:end]
ng-pipe-titlecasev4: Titlecase pipe
ng-pipe-uppercaseUppercase pipe
ng-propertyProperty: [property]="expression"
ng-repeatUse ngFor instead.
ng-route-guard-canactivateCanActivate Guard Route
ng-route-guard-canactivatechildCanActivateChild Route
ng-route-guard-candeactivateCanDeactivate Guard Route
ng-route-guard-canloadCanLoad Guard Route
ng-route-guard-resolveResolve Guard Route
ng-routerRouter template
ng-router-appmoduleRoutes to include in root module
ng-router-attributeRouter link
ng-router-featuremoduleRoutes to include in a feature module
ng-router-linkRouter link
ng-router-linkActiveRouter active link
ng-router-outletRouter outlet element
ng-router-outlet-nameRouter outlet element with name
ng-serviceBasic service
ng-showUsage: Bind to the hidden property.
ng-srcUsage: Bind to the src property.
ng-styleCSS style
ng-switchSwitch template
ng-test-directiveTODO
ng-test-serviceTODO
ng-validatorAngular validator snippet
ngrx-action-constngRx Single action
ngrx-action-creatorngRx Single action with const
ngrx-action-creator-enumngRx Single action creator for enum
ngrx-actionsngRx Actions class
ngrx-actiontype-enumngRx enum action type
ngrx-actiontypes-enumngRx enum action types
ngrx-effectngRx Effect
ngrx-modulengRx Root Module
ngrx-reducerngRx Reducer
ngrx-utilngRx Util
ngxs-actionNgxs Action
ngxs-action-payloadNgxs Action with Payload
ngxs-selectNgxs Select
ngxs-stateNgxs State
ngxs-state-modelNgxs State Model
ngxs-storeNgxs Store
ngxs-store-importNgxs Import Store
nx-cheatsheetNx Cheat Sheet
nx-ngrx-cheatsheetNx Cheat Sheet
pwa-link-manifestPWA Link Manifest
pwa-manifestPWA Json Manifest
rx-import-observableRxJS Import Observable
rx-import-operatorRxJS Import Add Operator
rx-import-subjectRxJS Import Subject
rx-mergeMapRxJS MergeMap Example
sw-registerRegister Service Worker
sw-register-and-checkRegister Service Worker and Check
t-afterAllafterAll
t-afterEachafterEach
t-beforeAllbeforeAll
t-beforeEachbeforeEach
t-component-asyncTODO
t-component-synchronousTODO
t-describe-itDescribe, It & Expect
t-itIt
t-iteIt and Expect
t-pipeTest a pipe
watA lightning talk by Gary Bernhardt from CodeMash 2012. ng-wat talk by Shai Reznik in 2015
  1. Launch VS Code
  2. Quick Open (⌘+P)
  3. Enter the following command and press enter: 'ext install Angular-BeastCode'
  4. Choose extension (Author: Mikael Morlund)
  5. Reload VS Code
  1. Launch VS Code
  2. Quick Open (Ctrl-Shift-P)
  3. Enter the following command and press enter: 'ext install Angular-BeastCode'
  4. Choose extension (Author: Mikael Morlund)
  5. Reload VS Code

If you want intellisense to show emmets before the snippets, you can force the emmets suggestions to show up at the top, by add the following to your editor user settings:

{
  "emmet.showSuggestionsAsSnippets": true,
  "editor.snippetSuggestions": "top"
}

Please send any feedback or suggestions to @Mike_BeastCode (Twitter) or create an issue on GitHub.

This is an open source project and if you want to contribute I've added issues on github that are easy to start with. first-timers-only

Important: This extension due to the nature of it's purpose will create files on your hard drive and if necessary create the respective folder structure. While it should not override any files during this process, I'm not giving any guarantees or take any responsibility in case of lost data.

MIT

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值