简体   繁体   中英

How to loop/count components in an angular2 app?

Basically the title says all. How would I loop through all of my components or just get the number of them in my project. Let's say I have 15 components in my angular2 application. How to display this number? Without including them in the main app.components.html ?

You can write a script that goes through your project and looks for components.

for windows: open a command prompt, navigate to yourproject/src , the following commant will return the amount of components:

dir /s | find /c "component.ts"

You can add >file.txt to the end to save this number a file.

Now you can read from this file from your application and display the number.

-

You can also leave out the /c for a list of all the components

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM