Issue
So, when I want to declare a new method in html of Angular component, webstorm provides me opportunity to create this method in ts:
But, if I try same at VS code I can't create a method. Is there some solution? (extensions, maybe something in settings)
Solution
You can use the extension My Code Actions v0.6.0.
Add this to your settings.json
"my-code-actions.actions": {
"[html]": {
"Create function {{atCursor:$1}}": {
"file": "${fileBasenameNoExtension}.ts",
"atCursor": "\\(click\\)=\"([^\"]+)\\(\\)\"",
"text": "function {{atCursor:$1}}() {\n}\n\n"
}
}
}
You can add more complex (multiple) edits if needed
You can have a look at the doc page of the extension to see an example of a complex edit to add / modify an import statement.
Adjust the languageID
if Angular template files are not html.
Answered By - rioV8
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.