简体   繁体   English

在我的 index.html 中需要逻辑来呈现来自服务的信息

[英]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.

相关问题 无法从angular2的查看文件夹中呈现index.html文件 - Unable to render index.html file from my view folder in angular2 AngularJS-需要在index.html页面中访问服务中的数据 - AngularJS - need access in index.html page to data from a service NodeJS-尝试呈现index.ejs文件,但仍然仅显示我的公用文件夹中的服务器index.html - NodeJS - Trying to render index.ejs file, but still only servers index.html that is in my public folder 使用 API 中的 HTML 而不是 index.html 中的静态 HTML 来为我的 React 应用程序补充水分 - Hydrate my React app with HTML from the API instead of static HTML from index.html 我的/index.html重定向到/ [object Object] - my /index.html is redirecting to /[object Object] 如何将index.html中的内容放入我的view.html? - How can I put content from my index.html into my view.html? html脚本不会根据AMP Validator从index.html中删除,但会从我这一边的index.html中删除 - html script won't remove from index.html according to AMP Validator but its removed from my index.html on my side Gulp服务:为所有路径呈现index.html - Gulp Serve: render index.html for all paths 将初始渲染构建为index.html文件 - Svelte build initial render to index.html file 来自index.html文件中的javascript的JSON - JSON from javascript in index.html file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM