简体   繁体   English

带有自定义html主题的angular 4项目

[英]angular 4 project with custom html theme

I am trying to create a angular 4 project from angular cli and I am trying to import a custom html theme.Theme has and css files js files and some font files. 我试图从angular cli创建一个angular 4项目,并且试图导入一个自定义html theme.theme具有和css文件js文件和一些字体文件。 Where put all those files?? 所有这些文件放在哪里? in asset folder?? 在资产文件夹中? And after that I will import them in index.html as script and links? 之后,我将它们作为脚本和链接导入到index.html中吗? With that way I am getting some errors "can't resolve the dependencies" like fonts.Exist other way more efficient and "more right" for the angular standards like through angular-cli.json or something else?? 通过这种方式,我遇到了一些“无法解决依赖项”的错误,例如字体。存在其他更有效和“更正确”的角度标准,例如通过angular-cli.json或其他方式? I have searched everywhere how I do this but no luck. 我到处都在搜索如何执行此操作,但是没有运气。

Firstly generate new component and you can use this component to design your own template and to add own CSS as follow:- 首先生成新组件,您可以使用该组件设计自己的模板并添加自己的CSS,如下所示:
firstly generate new component ng g component mycomponent new component will be created like below :- 首先生成新组件ng g组件mycomponent新组件将如下创建:-

mycomponent
    mytest.component.css
    mytest.component.html
    mytest.component.spec.ts
    mytest.component.ts

then you can add your styles at .CSS file, your all template at .html file and all logical content at .ts file 那么您可以在.CSS文件中添加样式,在.html文件中添加所有模板,并在.ts文件中添加所有逻辑内容

you can add this component at index.html 您可以在index.html上添加此组件
<app-mycomponent></app-mycomponent> // app-yourcomponent name <app-mycomponent></app-mycomponent> //应用组件名称

when you create the project i wonder you have a src folder. 当您创建项目时,我想知道您是否有一个src文件夹。 Inside this folder you have an assets folder: here you can paste all the code and images from your html code. 在此文件夹中,您有一个资产文件夹:在这里您可以粘贴html代码中的所有代码和图像。 Next, you have these options: 接下来,您有以下选择:

  1. Import the static files of your html theme one by one on the index.html in this way: 以此方式在index.html上一个一个地导入html主题的静态文件:

and so on.. 等等..

  1. In your angular-cli.json file: 在您的angular-cli.json文件中:

    "scripts": ["../src/assets/js/jquery.min.js"], “脚本”:[“ ../src/assets/js/jquery.min.js”],

and so on with all your code scripts. 等等所有的代码脚本。 The css styles have a styles array in the same angular-cli.json file. CSS样式在相同的angular-cli.json文件中具有样式数组。

Last but not least, if your html theme have images and other static content incorporated, you can access all this content in this way: 最后但并非最不重要的一点是,如果您的html主题结合了图像和其他静态内容,则可以通过以下方式访问所有这些内容:

<img src="../src/assets/images/logo.png" alt=""></a>

so, you access the local folder of any file with ../ and if you want to access a superior folder you can use ../../ and so on until you get in the root folder. 因此,您可以使用../访问任何文件的本地文件夹,如果要访问上级文件夹,则可以使用../../依此类推,直到进入根文件夹为止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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