admin管理员组文章数量:1434955
I have these two imports almost on every ponents module:
import { CommonModule } from '@angular/mon';
import { RouterModule } from '@angular/router';
Is it possible to only have them imported to the global appponent / module where they can be shared?
I'm wanting to be more efficient with my imports because it seems to be effecting my app loading.
Currently my app takes 4 seconds to load and I believe its because of the imports. I have many and want to refactor how I use them.
Also, I'm open to other ideas on how best to import.
My overall goal is to speed up my app down to 2 seconds by doing less imports on all my ponents.
I have these two imports almost on every ponents module:
import { CommonModule } from '@angular/mon';
import { RouterModule } from '@angular/router';
Is it possible to only have them imported to the global app.ponent / module where they can be shared?
I'm wanting to be more efficient with my imports because it seems to be effecting my app loading.
Currently my app takes 4 seconds to load and I believe its because of the imports. I have many and want to refactor how I use them.
Also, I'm open to other ideas on how best to import.
My overall goal is to speed up my app down to 2 seconds by doing less imports on all my ponents.
Share Improve this question asked Dec 5, 2016 at 23:13 AngularMAngularM 16.6k29 gold badges104 silver badges175 bronze badges 10- What makes you think it's the imports? If speed is an issue, have you looked into AOT pilation? – jonrsharpe Commented Dec 5, 2016 at 23:14
- My app when I run it always has a delay of four seconds on load and refresh. – AngularM Commented Dec 5, 2016 at 23:16
- That answers neither question... – jonrsharpe Commented Dec 5, 2016 at 23:17
- I've had a look at that and it looks hard to implement. I'm new to angular 2. I'm using an angular 2 app with typescript and systemjs currently – AngularM Commented Dec 5, 2016 at 23:19
- "My overall goal is to speed up my app down to 2 seconds" - OK! "by doing less imports" - see above. What if you do fewer imports and performance doesn't improve? "it looks hard to implement" - that doesn't mean it isn't worth doing, if you have a specific performance issue. – jonrsharpe Commented Dec 5, 2016 at 23:20
1 Answer
Reset to default 2You can create a shared module and export all the modules or ponents you want to use in the application, then all you need is just to import that shared module.
That's how you can create a shared module: SharedModule
本文标签:
版权声明:本文标题:javascript - In angular2 is it possible to import CommonModule and RouterModule in a global place for app speed - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745627887a2667084.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论