Skip to content

Instantly share code, notes, and snippets.

@alonbalbuena
Last active July 17, 2024 12:37
Show Gist options
  • Save alonbalbuena/40fb459df1c8ad61ec97c2b535d3ed8e to your computer and use it in GitHub Desktop.
Save alonbalbuena/40fb459df1c8ad61ec97c2b535d3ed8e to your computer and use it in GitHub Desktop.
File Template for Angular components in Webstorm
import { ChangeDetectionStrategy, Component } from '@angular/core';
#set($componentName = "")
#foreach($str in $NAME.split("-"))
#set($str = $str.substring(0,1).toUpperCase()+$str.substring(1))
#set($componentName = $componentName + $str)
#end
@Component({
selector: 'app-${NAME}',
templateUrl: './${NAME}.component.html',
styleUrl: './${NAME}.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
})
export class ${componentName}Component {
}
@alonbalbuena
Copy link
Author

alonbalbuena commented Jun 18, 2024

This way you can create the folder where all the files will be stored.

${NAME}/${NAME}.component

image

@alonbalbuena
Copy link
Author

alonbalbuena commented Jun 18, 2024

This way you can the complete folder for the component.

image

Create child templates for the Angular component.

image

One for HTML and Use the same File Name than the component in a "html" extension file

image

<div class="app-${NAME}">
</div>

And one for SCSS

image

.app-${NAME}{

}

@alonbalbuena
Copy link
Author

alonbalbuena commented Jun 18, 2024

Now when you create a file of angular
image
image

It creates the full folder.

image

import { ChangeDetectionStrategy, Component } from '@angular/core';
@Component({
  selector: 'app-test-component',
  templateUrl: './test-component.component.html',
  styleUrl: './test-component.component.scss',
  changeDetection: ChangeDetectionStrategy.OnPush,
  standalone: true,
})
export class TestComponentComponent {

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment