html - Angular index和app.component.html应该怎么写?

标签 html angular web-applications architecture components

我目前正在学习 Angular 并想知道究竟应该在 index.html 和 app.component.html 中编码什么,而不是在组件中编码。

我目前的 Angular 项目是我的个人网站,我想将其迁移到 Angular 以便进行训练。您可以在 http://www.chloe-seiler.com/ 找到它

-不要管响应度,我正在努力。-

基本上有标题、导航和正文。主体仅在导航时有所不同,标题和导航保留在整个网站中。

我应该在 index.html 中编写标题和新内容吗?或者在 app.component.html 中?或者我应该让它们成为组件,在这种情况下:我的 index.html 和我的 app.component.html 是否保持为空?

在此先感谢您的帮助!

最佳答案

index.html : 对于开发个人网站等基础应用,可以使用index.html来包含css、js、icon、fonts和设置title,放入user定义的脚本。

app.component.html :这应包含应用程序级组件的组件 View 。现在一个好的做法是在您的应用程序中为每个组件使用路由。然后你可以把

<router-outlet></router-outlet> 

标记以显示您的路由组件。 Here is a simple example of routing.如果您不使用多个组件,您可以只使用 app.component.html 来显示应用级组件。

关于html - Angular index和app.component.html应该怎么写?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52018602/

相关文章:

html - 如何在保持文本元素不透明的同时仅使 CSS 中的导航栏透明?

html - 模态关闭后文本模糊

javascript - 如何以非阻塞方式组合可观察对象?

angular - 更新 cli 版本后创建新的 angular 项目时出错

security - 访问未授权/未找到资源时出现404 Not Found?

css - 页脚连接到页眉 wordpress

html - 如何仅使用 css 显示简单的图标

jquery - 如何在加载页面时显示此模式弹出窗口

javascript - 从网页运行 Google App 脚本

web-applications - cache.manifest 第一次工作然后失败