[英]Need logic in my index.html to render information from services
I'm developing a web app using Angular 7.1.我正在使用 Angular 7.1 开发一个 Web 应用程序。 I have no pre-experience with that framework.
我没有使用该框架的经验。 The project does already have a localization (two languages).
该项目已经进行了本地化(两种语言)。 I want to add meta tags in my
<head>
and also a fitting html lang attribute.我想在我的
<head>
添加元标记以及一个合适的 html lang 属性。 But all the logic and all the components start at <app-root></app-root>
.但是所有逻辑和所有组件都从
<app-root></app-root>
。 There is no .js or .ts file for index.html. index.html 没有 .js 或 .ts 文件。 I don't know how I could access my
translateService
to get the current language.我不知道如何访问我的
translateService
以获取当前语言。
Of course I googled on the problem.当然,我用谷歌搜索了这个问题。 But no solution did work or could be implemented in my project.
但是没有解决方案有效或可以在我的项目中实施。 It is like they were using old versions of Angular that had a whole other structure.
就好像他们在使用具有完全不同结构的旧版本 Angular。 Sometimes they would provide JS code and no word about where it is supposed to be.
有时他们会提供 JS 代码,但没有说明它应该在哪里。
index.html
索引.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My app</title>
<base href="/">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-root></app-root>
</body>
</html>
The index.html is in the root directory of my application. index.html 位于我的应用程序的根目录中。
I think firstly, you have not actually linked the Angular Framework nor any other external Javascript file in your HTML file.我认为首先,您实际上并没有在 HTML 文件中链接 Angular 框架或任何其他外部 Javascript 文件。
So, therefore, your tag <app-root></app-root>
will not work.因此,您的标签
<app-root></app-root>
将不起作用。
Aside from that, I think you need to provide more information about your problem since I don't see translateService
anywhere in the code you say you are trying to access.除此之外,我认为您需要提供有关您的问题的更多信息,因为我在您说要访问的代码中的任何地方都没有看到
translateService
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.