简体   繁体   English

在Angular 2中使用HTML5主题

[英]Using a HTML5 Theme in Angular 2

I am wondering how can i set up my current Theme that is designed using bootstrap and some css and js 我想知道如何设置使用Bootstrap和一些CSS和JS设计的当前主题

I am using following css and js files in my theme and i don't want to put it in index.html like we did in angular 1 can any one tell me how to import all css and js effectively without compromising Angular 2 structure and behaviour. 我正在主题中使用以下css和js文件,但我不想像在angular 1中那样将其放入index.html中,任何人都可以告诉我如何有效导入所有css和js而不会影响Angular 2的结构和行为。

<link href="assets/plugins/pace/pace-theme-flash.css" rel="stylesheet" type="text/css" />
    <link href="assets/plugins/boostrapv3/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="assets/plugins/font-awesome/css/font-awesome.css" rel="stylesheet" type="text/css" />
    <link href="assets/plugins/jquery-scrollbar/jquery.scrollbar.css" rel="stylesheet" type="text/css" media="screen" />
    <link href="assets/plugins/bootstrap-select2/select2.css" rel="stylesheet" type="text/css" media="screen" />
    <link href="assets/plugins/switchery/css/switchery.min.css" rel="stylesheet" type="text/css" media="screen" />
    <link href="theme/css/theme-icons.css" rel="stylesheet" type="text/css">
    <link class="main-stylesheet" href="theme/css/theme.css" rel="stylesheet" type="text/css" />
    <link href="theme/css/style.css" rel="stylesheet" type="text/css" />

Js files js文件

 <script src="assets/plugins/pace/pace.min.js" type="text/javascript"></script>
    <script src="assets/plugins/jquery/jquery-1.11.1.min.js" type="text/javascript"></script>
    <script src="assets/plugins/modernizr.custom.js" type="text/javascript"></script>
    <script src="assets/plugins/jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
    <script src="assets/plugins/boostrapv3/js/bootstrap.min.js" type="text/javascript"></script>
    <script src="assets/plugins/jquery/jquery-easy.js" type="text/javascript"></script>
    <script src="assets/plugins/jquery-unveil/jquery.unveil.min.js" type="text/javascript"></script>
    <script src="assets/plugins/jquery-bez/jquery.bez.min.js"></script>
    <script src="assets/plugins/jquery-ios-list/jquery.ioslist.min.js" type="text/javascript"></script>
    <script src="assets/plugins/jquery-actual/jquery.actual.min.js"></script>
    <script src="assets/plugins/jquery-scrollbar/jquery.scrollbar.min.js"></script>
    <script type="text/javascript" src="assets/plugins/bootstrap-select2/select2.min.js"></script>
    <script type="text/javascript" src="assets/plugins/classie/classie.js"></script>
    <script src="assets/plugins/switchery/js/switchery.min.js" type="text/javascript"></script>
    <script src="assets/plugins/jquery-validation/js/jquery.validate.min.js" type="text/javascript"></script>

I tried using ng2-bootstrap and bootstrap but can not get it working. 我尝试使用ng2-bootstrap和bootstrap,但无法正常工作。

Your problem is your loading straight bootstrap along with jquery plugins instead of a something like angular-ui-bootstrap. 您的问题是您将直接引导程序与jquery插件一起加载,而不是像angular-ui-bootstrap这样的加载程序。 Some boostrap stuff uses pure CSS(no compatibility issues) and others use jquery/ which can work iffy with Angular1/2 sometimes hence projects like angular-ui-bootstrap. 一些boostrap东西使用纯CSS(不存在兼容性问题),而其他人使用jquery /可以与Angular1 / 2配合使用,有时因此会出现诸如angular-ui-bootstrap之类的项目。


try the angular 2 version https://ng-bootstrap.github.io/ then load all the css files using webpack(just putting in the same css folder the current project css files are). 尝试使用角度2版本https://ng-bootstrap.github.io/,然后使用webpack加载所有css文件(只需将当前项目css文件放入相同的css文件夹中)。 Obviously you would need to change the existing bootstrap javascript code to angular-ui directives. 显然,您需要将现有的引导javascript代码更改为angular-ui指令。

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

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