BeastCode / VSCode-Angular-TypeScript-Snippets

Visual Studio Code TypeScript snippets (TypeScript, Html, Angular Material, Flex Layout, ngRx, RxJS & Testing) for Angular 17
https://marketplace.visualstudio.com/items?itemName=Mikael.Angular-BeastCode
MIT License
92 stars 49 forks source link

ng-router #28

Closed cgatian closed 7 years ago

cgatian commented 7 years ago

snippet: ng-router

issue: Extra parenethsis at he end of the routes array

Generated Code

import { Routes } from '@angular/router';

import { HomeComponent } from './';
import { Name2Component } from './';
import { Name3Component } from './';
import { Name4Component } from './';
import { PageNotFoundComponent } from './';

const routes: Routes = [
  { path: '', component: HomeComponent },
  { path: 'path2', component: Name2Component },
  { path: 'path3', component: Name3Component },
  { path: 'path4', component: Name4Component },
  { path: '**', component: PageNotFoundComponent },

  //{ path: 'path/:routeParam', component: MyComponent },
  //{ path: 'staticPath', component: ... },
  //{ path: '**', component: ... },
  //{ path: 'oldPath', redirectTo: '/staticPath' },
  //{ path: ..., component: ..., data: { message: 'Custom' }
]);

Last line has ]); which should be ];

cgatian commented 7 years ago

This snippet should probably also export the routes array.

BeastCode commented 7 years ago

Fixed in v4.2.4

cgatian commented 7 years ago

Wow, that was.... fast 🚀

BeastCode commented 7 years ago

I took a look and found the same bug in two other places :( So decided to fix it right away.

If you plan on submitting a pull request just add a note in the description sand I'll leave them alone.

Thanks again!

cgatian commented 7 years ago

👍

cgatian commented 7 years ago

@BeastCode Suggestion to rename the exported module from FeatureModule to FeatureRoutingModule

This would align with the convention used in the docs

@NgModule({
  imports: [RouterModule.forChild(routes)]
  exports: [RouterModule]
})
export class FeatureModule {}
BeastCode commented 7 years ago

Nice catch! fixed in v4.2.5