You can use CLI command ng generate directive
to create the directive class file. It creates the source file(src/app/components/directivename.directive.ts
), the respective test file(.spec.ts) and declare the directive class file in root module.
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.