/
bear
/
my_snippets
Обзор
Документация
Войти
/
bear
/
my_snippets
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
data/Angular.xml
256 строк
28 KB
Nikita Kalitin
delete duplicate code and added function readAndDaraw, add some snippets in xml
28 окт 2019, 10:38
28 окт 2019, 10:38
a037f04
Код
Авторство
О чём код?
<templateSet group="Angular"> <template name="a-class" value="[class]="$expression$"" description="Angular [class] binding" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="expression" expression="" defaultValue=""expression"" alwaysStopAt="true" /> <context /> </template> <template name="a-ngClass" value="[ngClass]="{$cssClass$: $expression$}"" description="Angular ngClass" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="cssClass" expression="" defaultValue=""cssClass"" alwaysStopAt="true" /> <variable name="expression" expression="" defaultValue=""expression"" alwaysStopAt="true" /> <context /> </template> <template name="a-ngFor" value="*ngFor="let $item$ of $list$"$END$" description="Angular *ngFor" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="item" expression="" defaultValue=""item"" alwaysStopAt="true" /> <variable name="list" expression="" defaultValue=""list"" alwaysStopAt="true" /> <context /> </template> <template name="a-ngFor-trackBy" value="*ngFor="let $item$ of $list$; trackBy:$item$.id"$END$" description="Angular *ngFor with trackBy" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="item" expression="" defaultValue=""item"" alwaysStopAt="true" /> <variable name="list" expression="" defaultValue=""list"" alwaysStopAt="true" /> <context /> </template> <template name="a-ngForAsync" value="*ngFor="let $item$ of $stream$ | async as $list$"$END$" description="Angular *ngForAsync" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="item" expression="" defaultValue=""item"" alwaysStopAt="true" /> <variable name="stream" expression="" defaultValue=""stream"" alwaysStopAt="true" /> <variable name="list" expression="" defaultValue=""list"" alwaysStopAt="true" /> <context /> </template> <template name="a-formControlName" value="formControlName="$control$"" description="Angular formControlName" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="control" expression="" defaultValue=""control"" alwaysStopAt="true" /> <context /> </template> <template name="a-formGroup" value="[formGroup]="$form$"" description="Angular formGroup" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="form" expression="" defaultValue=""form"" alwaysStopAt="true" /> <context /> </template> <template name="a-formGroupName" value="[formGroupName]="$name$"" description="Angular formGroupName" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="name" expression="" defaultValue=""name"" alwaysStopAt="true" /> <context /> </template> <template name="a-ngIf" value="*ngIf="$expression$"" description="Angular *ngIf" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="expression" expression="" defaultValue=""expression"" alwaysStopAt="true" /> <context /> </template> <template name="a-ngIfElse" value="*ngIf="$expression$;else $templateName$"" description="Angular *ngIfElse" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="expression" expression="" defaultValue=""expression"" alwaysStopAt="true" /> <variable name="templateName" expression="" defaultValue=""templateName"" alwaysStopAt="true" /> <context /> </template> <template name="a-ngModel" value="[(ngModel)]="$binding$"" description="Angular ngModel" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="binding" expression="" defaultValue=""binding"" alwaysStopAt="true" /> <context /> </template> <template name="a-routerLink" value="[routerLink]="['/$routePath$']" routerLinkActive="$router_link-active$" $END$" description="Angular routerLink" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="routePath" expression="" defaultValue=""routePath"" alwaysStopAt="true" /> <variable name="router_link-active" expression="" defaultValue=""router-link-active"" alwaysStopAt="true" /> <context /> </template> <template name="a-routerLink-param" value="[routerLink]="['$routePath$', $routeParameterValue$]" routerLinkActive="$router_link-active$"$END$" description="Angular routerLink with a route parameter" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="routePath" expression="" defaultValue=""routePath"" alwaysStopAt="true" /> <variable name="routeParameterValue" expression="" defaultValue=""routeParameterValue"" alwaysStopAt="true" /> <variable name="router_link-active" expression="" defaultValue=""router-link-active"" alwaysStopAt="true" /> <context /> </template> <template name="a-select" value="<select [(ngModel)]="$model$"> <option *ngFor="let $item$ of $list$" [value]="$item$">{{$item$}}</option> </select>" description="<select> control with ngModel" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="model" expression="" defaultValue=""model"" alwaysStopAt="true" /> <variable name="item" expression="" defaultValue=""item"" alwaysStopAt="true" /> <variable name="list" expression="" defaultValue=""list"" alwaysStopAt="true" /> <context /> </template> <template name="a-ngStyle" value="[ngStyle]="{$style$: $expression$}"" description="Angular ngStyle" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="style" expression="" defaultValue=""style"" alwaysStopAt="true" /> <variable name="expression" expression="" defaultValue=""expression"" alwaysStopAt="true" /> <context /> </template> <template name="a-ngSwitch" value="<div [ngSwitch]="$conditionExpression$"> <div *ngSwitchCase="$expression$">$output$</div> <div *ngSwitchDefault>$output2$</div> </div>" description="Angular ngSwitch" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="conditionExpression" expression="" defaultValue=""conditionExpression"" alwaysStopAt="true" /> <variable name="expression" expression="" defaultValue=""expression"" alwaysStopAt="true" /> <variable name="output" expression="" defaultValue=""output"" alwaysStopAt="true" /> <variable name="output2" expression="" defaultValue=""output2"" alwaysStopAt="true" /> <context /> </template> <template name="a-preja" value="<pre>{{$model$ | async | json}}</pre>$END$" description="Angular pre debug | async | json" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="model" expression="" defaultValue=""model"" alwaysStopAt="true" /> <context /> </template> <template name="a-prej" value="<pre>{{$model$ | json}}</pre>$END$" description="Angular pre debug | json" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="model" expression="" defaultValue=""model"" alwaysStopAt="true" /> <context /> </template> <template name="a-style" value="[style.$property$]="$expression$"" description="Angular [style] binding" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="property" expression="" defaultValue=""property"" alwaysStopAt="true" /> <variable name="expression" expression="" defaultValue=""expression"" alwaysStopAt="true" /> <context /> </template> <template name="a-route-path-404" value="{ path: '**', pathMatch: 'full', component: $PathNotFoundComponent$ }$END$" description="Angular 404 route path" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="PathNotFoundComponent" expression="" defaultValue=""PathNotFoundComponent"" alwaysStopAt="true" /> <context /> </template> <template name="a-guard-can-activate" value="import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot } from '@angular/router'; @Injectable() export class $Name$Guard implements CanActivate { constructor() { } canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { return true;$END$ } }" description="Angular CanActivate guard" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="Name" expression="" defaultValue=""Name"" alwaysStopAt="true" /> <context /> </template> <template name="a-guard-can-activate-child" value="import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, CanActivateChild, RouterStateSnapshot } from '@angular/router'; @Injectable() export class $Name$Guard implements CanActivateChild { constructor() { } canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { return true;$END$ } }" description="Angular CanActivateChild guard" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="Name" expression="" defaultValue=""Name"" alwaysStopAt="true" /> <context /> </template> <template name="a-guard-can-deactivate" value="import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, CanDeactivate, RouterStateSnapshot } from '@angular/router'; import { Observable } from 'rxjs/Observable'; import { $ComponentName$Component } from './$filename$.component'; // Consider using this interface for all CanDeactivate guards, // and have your components implement this interface, too. // // e.g. export class CanDeactivateGuard implements CanDeactivate<CanComponentDeactivate> { // // export interface CanComponentDeactivate { // canDeactivate: () => any; // } @Injectable() export class $Name$Guard implements CanDeactivate<$ComponentName$Component> { canDeactivate( component: $ComponentName$Component, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot ): Observable<boolean>|Promise<boolean>|boolean { return false;$END$ } }" description="Angular CanDeactivate guard" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="ComponentName" expression="" defaultValue=""ComponentName"" alwaysStopAt="true" /> <variable name="filename" expression="lowercaseAndDash(ComponentName)" defaultValue="" alwaysStopAt="true" /> <variable name="Name" expression="" defaultValue=""Name"" alwaysStopAt="true" /> <context /> </template> <template name="a-guard-can-load" value="import { Injectable } from '@angular/core'; import { CanLoad, Route } from '@angular/router'; @Injectable() export class $Name$Guard implements CanLoad { constructor() { } canLoad(route: Route) { return true;$END$ } }" description="Angular CanLoad guard" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="Name" expression="" defaultValue=""Name"" alwaysStopAt="true" /> <context /> </template> <template name="a-component" value="import { Component, OnInit } from '@angular/core'; @Component({ selector: '$selector_name$', templateUrl: '$name$.component.html' }) export class $Name$Component implements OnInit { constructor() { } ngOnInit() { }$END$ }" description="Angular component" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="Name" expression="" defaultValue=""Name"" alwaysStopAt="true" /> <variable name="name" expression="lowercaseAndDash(Name)" defaultValue="" alwaysStopAt="true" /> <variable name="selector_name" expression="lowercaseAndDash(Name)" defaultValue="" alwaysStopAt="true" /> <context /> </template> <template name="a-component-inline" value="import { Component, OnInit } from '@angular/core'; @Component({ selector: '$selector_name$', template: `$END$` }) export class $Name$Component implements OnInit { constructor() { } ngOnInit() { } }" description="Angular component with an inline template" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="Name" expression="" defaultValue=""Name"" alwaysStopAt="true" /> <variable name="selector_name" expression="lowercaseAndDash(Name)" defaultValue="" alwaysStopAt="true" /> <context /> </template> <template name="a-route-path-default" value="{ path: '', pathMatch: 'full', redirectTo: '$path$' }$END$" description="Angular default route path" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="path" expression="" defaultValue=""path"" alwaysStopAt="true" /> <context /> </template> <template name="a-directive" value="import { Directive } from '@angular/core'; @Directive({ selector: '[$selector_name$]' }) export class $Name$Directive { constructor() { } }" description="Angular directive" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="Name" expression="" defaultValue=""Name"" alwaysStopAt="true" /> <variable name="selector_name" expression="lowercaseAndDash(Name)" defaultValue="" alwaysStopAt="true" /> <context /> </template> <template name="a-route-path-eager" value="{ path: '$path$', component: $Name$Component }," description="Angular eager route path" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="path" expression="" defaultValue=""path"" alwaysStopAt="true" /> <variable name="Name" expression="" defaultValue=""Name"" alwaysStopAt="true" /> <context /> </template> <template name="a-service-http" value="import { Injectable } from '@angular/core'; import { Http, Response } from '@angular/http'; import { Observable } from 'rxjs/Observable'; import 'rxjs/add/operator/map'; import 'rxjs/add/operator/catch'; @Injectable() export class $ServiceName$Service { constructor(private http: Http) { } $END$ }" description="Angular service with Http" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="ServiceName" expression="" defaultValue=""ServiceName"" alwaysStopAt="true" /> <context /> </template> <template name="a-service-httpclient" value="import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { catchError } from 'rxjs/operators'; @Injectable() export class $ServiceName$Service { constructor(private httpClient: HttpClient) { } $END$ }" description="Angular service with HttpClient" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="ServiceName" expression="" defaultValue=""ServiceName"" alwaysStopAt="true" /> <context /> </template> <template name="a-http-interceptor" value="import { Injectable } from '@angular/core'; import { HttpInterceptor, HttpEvent, HttpHandler, HttpRequest } from '@angular/common/http'; import { Observable } from 'rxjs/Observable'; @Injectable() export class HeaderInterceptor implements HttpInterceptor { intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { return next.handle(req); } }" description="Empty Angular HttpInterceptor for HttpClient" toReformat="true" toShortenFQNames="true" deactivated="true"> <context /> </template> <template name="a-http-interceptor-headers" value="import { Injectable } from '@angular/core'; import { HttpEvent, HttpInterceptor, HttpHandler, HttpRequest } from '@angular/common/http'; import { Observable } from 'rxjs/Observable'; @Injectable() export class HeaderInterceptor implements HttpInterceptor { constructor() {} intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { const headers = req.headers .set('Content-Type', 'application/json'); const authReq = req.clone({ headers }); return next.handle(authReq); } }" description="Angular HttpInterceptor for headers HttpClient" toReformat="true" toShortenFQNames="true" deactivated="true"> <context /> </template> <template name="a-http-interceptor-logging" value="import { HttpInterceptor, HttpHandler, HttpRequest, HttpEvent, HttpResponse } from '@angular/common/http'; import { Observable } from 'rxjs/Observable'; import { tap } from 'rxjs/operators'; export class LogInterceptor implements HttpInterceptor { constructor() {} intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { const started = Date.now(); return next.handle(req).pipe( tap(event => { if (event instanceof HttpResponse) { const elapsed = Date.now() - started; console.log(`Request for \${req.urlWithParams} took \$elapsed$ ms.`); } }) ); } }" description="Angular HttpInterceptor for Logging HttpClient" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="elapsed" expression="" defaultValue="""" alwaysStopAt="true" /> <context /> </template> <template name="a-route-path-lazy" value="{ path: '$path$', loadChildren: '$lazy_path$#$lazy_module$' }," description="Angular lazy route path" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="path" expression="" defaultValue=""path"" alwaysStopAt="true" /> <variable name="lazy_path" expression="" defaultValue=""lazy-path"" alwaysStopAt="true" /> <variable name="lazy_module" expression="" defaultValue=""lazy-module"" alwaysStopAt="true" /> <context /> </template> <template name="a-module" value="import { NgModule } from '@angular/core'; import { $Name$Component } from './$name$.component'; @NgModule({ imports: [], exports: [], declarations: [$Name$Component], providers: [], }) export class $Name$Module { } $END$" description="Angular Module" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="Name" expression="" defaultValue=""Name"" alwaysStopAt="true" /> <variable name="name" expression="lowercaseAndDash(Name)" defaultValue="" alwaysStopAt="true" /> <context /> </template> <template name="a-ctor-skip-self" value="constructor( @Optional() @SkipSelf() parentModule: $ModuleName$ { if (parentModule) { const msg = `$ModuleName$ has already been loaded. Import $ModuleName$ once, only, in the root AppModule.`; throw new Error(msg); } }" description="Angular Module SkipSelf constructor" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="ModuleName" expression="" defaultValue=""ModuleName"" alwaysStopAt="true" /> <context /> </template> <template name="a-pipe" value="import { Pipe, PipeTransform } from '@angular/core'; @Pipe({ name: '$selector_name$' }) export class $Name$Pipe implements PipeTransform { transform(value: any, ...args: any[]): any { $END$ } }" description="Angular pipe" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="Name" expression="" defaultValue=""Name"" alwaysStopAt="true" /> <variable name="selector_name" expression="lowercaseAndDash(Name)" defaultValue="" alwaysStopAt="true" /> <context /> </template> <template name="a-component-root" value="import { Component } from '@angular/core'; @Component({ selector: '$prefix_app$', template: ` <router-outlet></router-outlet> ` }) export class $App$Component { } $END$" description="Angular App root component" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="prefix_app" expression="" defaultValue=""prefix-app"" alwaysStopAt="true" /> <variable name="App" expression="" defaultValue=""App"" alwaysStopAt="true" /> <context /> </template> <template name="a-module-root" value="import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { HttpModule } from '@angular/http'; import { $App$Component } from './$app$.component'; import { AppRoutingModule } from './$app$.routing'; //TODO: Create $app$.routing @NgModule({ imports: [ BrowserModule, HttpModule, AppRoutingModule, ], declarations: [$App$Component], providers: [/* TODO: Providers go here */], bootstrap: [$App$Component], }) export class $App$Module { } $END$" description="Angular Root Module" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="App" expression="" defaultValue=""App"" alwaysStopAt="true" /> <variable name="app" expression="lowercaseAndDash(App)" defaultValue="" alwaysStopAt="true" /> <context /> </template> <template name="a-route-path-with-children" value="{ path: '', component: $Component$, children: [ { path: '$childpath$', component: $ChildComponent$ } ] }$END$" description="Angular route path with children" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="Component" expression="" defaultValue=""Component"" alwaysStopAt="true" /> <variable name="childpath" expression="" defaultValue=""childpath"" alwaysStopAt="true" /> <variable name="ChildComponent" expression="" defaultValue=""ChildComponent"" alwaysStopAt="true" /> <context /> </template> <template name="a-router-events" value="checkEvents() { this.router.events.subscribe(event => { switch (true) { case event instanceof $eventName$: $END$ break; default: break; } }); }" description="Angular Router Events" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="eventName" expression="" defaultValue=""eventName"" alwaysStopAt="true" /> <context /> </template> <template name="a-module-routing" value="import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { $Name$Component } from './$name$.component'; const routes: Routes = [ { path: '$path$', component: $Name$Component }, ]; @NgModule({ imports: [RouterModule.forChild(routes)], exports: [RouterModule], }) export class $Name$RoutingModule { } export const routedComponents = [$Name$Component];" description="Angular routing module file (forChild)" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="Name" expression="" defaultValue=""Name"" alwaysStopAt="true" /> <variable name="name" expression="lowercaseAndDash(Name)" defaultValue="" alwaysStopAt="true" /> <variable name="path" expression="" defaultValue=""path"" alwaysStopAt="true" /> <context /> </template> <template name="a-service" value="import { Injectable } from '@angular/core'; @Injectable() export class $Name$Service { $END$ constructor() { } }" description="Angular service" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="Name" expression="" defaultValue=""Name"" alwaysStopAt="true" /> <context /> </template> <template name="a-http-get" value="return this.http.get('$url$') .map((response: Response) => response.json());$END$" description="Angular Http.get" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="url" expression="" defaultValue=""url"" alwaysStopAt="true" /> <context /> </template> <template name="a-httpclient-get" value="return this.httpClient.get('$url$');$END$" description="Angular HttpClient.get" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="url" expression="" defaultValue=""url"" alwaysStopAt="true" /> <context /> </template> <template name="a-output-event" value="@Output() $eventName$ = new EventEmitter<$eventType$>();" description="Angular @Output event and emitter" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="eventName" expression="" defaultValue=""eventName"" alwaysStopAt="true" /> <variable name="eventType" expression="" defaultValue=""eventType"" alwaysStopAt="true" /> <context /> </template> <template name="a-route-params-subscribe" value="this.route.params .pipe(map(params => params['id']), tap(id => (this.id = +id))) .subscribe(id => ${1:function()}()); $END$" description="Angular - subscribe to routing parameters" toReformat="true" toShortenFQNames="true" deactivated="true"> <context /> </template> <template name="rx-add-observable" value="import 'rxjs/add/observable/$of$'; $END$" description="RxJS Add Observable import" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="of" expression="" defaultValue=""of"" alwaysStopAt="true" /> <context /> </template> <template name="rx-add-operator" value="import 'rxjs/add/operator/$map$'; $END$" description="RxJS Add Operator import" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="map" expression="" defaultValue=""map"" alwaysStopAt="true" /> <context /> </template> <template name="rx-behavior-subject" value="import { BehaviorSubject } from 'rxjs/BehaviorSubject'; $END$" description="RxJS BehaviorSubject import" toReformat="true" toShortenFQNames="true" deactivated="true"> <context /> </template> <template name="rx-observable" value="import { Observable } from 'rxjs/Observable'; $END$" description="RxJS Observable import" toReformat="true" toShortenFQNames="true" deactivated="true"> <context /> </template> <template name="rx-operators" value="import { $map$ } from 'rxjs/operators'; $END$" description="RxJS Operators import" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="map" expression="" defaultValue=""map"" alwaysStopAt="true" /> <context /> </template> <template name="rx-replay-subject" value="import { ReplaySubject } from 'rxjs/ReplaySubject'; $END$" description="RxJS ReplaySubject import" toReformat="true" toShortenFQNames="true" deactivated="true"> <context /> </template> <template name="rx-subject" value="import { Subject } from 'rxjs/Subject'; $END$" description="RxJS Subject import" toReformat="true" toShortenFQNames="true" deactivated="true"> <context /> </template> <template name="a-subscribe" value="this.$service$.$function$ .subscribe($arg$ => this.$property$ = $arg$); $END$" description="Angular observable subscribe" toReformat="true" toShortenFQNames="true" deactivated="true"> <variable name="service" expression="" defaultValue=""service"" alwaysStopAt="true" /> <variable name="function" expression="" defaultValue=""function"" alwaysStopAt="true" /> <variable name="arg" expression="" defaultValue=""arg"" alwaysStopAt="true" /> <variable name="property" expression="" defaultValue=""property"" alwaysStopAt="true" /> <context /> </template> </templateSet>