简体   繁体   English

在我的angular 2应用程序中集成bootstrap 4 popover时出现错误

[英]I am getting error while integrating bootstrap 4 popover in my angular 2 application

I am using Angular 2 RC 5 version. 我正在使用Angular 2 RC 5版本。 In my angular 2 application I am using system.config.js in that I have mapped ng2-boostrap package like below 在我的angular 2应用程序中,我正在使用system.config.js,因为我已经映射了ng2-boostrap包,如下所示

var map={
'ng2-bootstrap/ng2-bootstrap': 'node_modules/ng2-bootstrap/ng2-bootstrap',
}

and in app module file i am importing it like below 在应用程序模块文件中,我将其导入如下

import {PopoverModule   } from 'ng2-bootstrap/ng2-bootstrap';

@NgModule({
  imports: [PopoverModule.forRoot()]
})

Using all of above, still I am getting an error in browser's console as below 使用以上所有内容,仍然在浏览器的控制台中出现如下错误

Error: (SystemJS) Cannot read property 'forRoot' of undefined TypeError: Cannot read property 'forRoot' of undefined at eval ( http://localhost:3000/assets/app.module.js:259:149 ) at execute ( http://localhost:3000/assets/app.module.js:270:14 ) Error loading http://localhost:3000/assets/main.js 错误:(SystemJS)无法读取在执行( http :// localhost:3000 / assets / app.module.js:259:149 )时在eval( http:// localhost:3000 / assets / app.module.js:259:149 )处无法读取的undefined属性'forRoot' :// localhost:3000 / assets / app.module.js:270:14 )加载http:// localhost:3000 / assets / main.js时出错

I am referring this link https://valor-software.com/ng2-bootstrap/index-bs4.html#/popover 我指的是此链接https://valor-software.com/ng2-bootstrap/index-bs4.html#/popover

Not sure about the library you are referring but here are few observations: 不确定您要引用的库,但以下是一些观察结果:

  • You are using a very old version of Angular - you should update to the latest 2.x or consider 4.x straight away 您使用的是Angular的非常旧的版本-您应该更新到最新的2.x或立即考虑使用4.x
  • If you are willing to explore different approaches here is an excellent library that has all the Bootstrap components, including popover: https://ng-bootstrap.github.io/#/components/popover 如果您愿意探索不同的方法,这里是一个优秀的库,其中包含所有Bootstrap组件,包括popover: https ://ng-bootstrap.github.io/#/components/popover

The mentioned library is known to work with Angular 2.x and 4.x and is very simple to use: 提到的库已知可以与Angular 2.x和4.x一起使用,并且使用非常简单:

<button type="button" class="btn btn-secondary" placement="top"
        ngbPopover="Vivamus sagittis lacus vel augue laoreet rutrum faucibus." popoverTitle="Popover on top">
  Popover on top
</button>

You can see it in action in this minimal plunk (it should help you configure SystemJS and other files in your project): http://plnkr.co/edit/pTZpUjpmAe2Pc1jxO2u0?p=preview 您可以通过最小的操作看到它的实际效果(它应该有助于您在项目中配置SystemJS和其他文件): http ://plnkr.co/edit/pTZpUjpmAe2Pc1jxO2u0?p=preview

暂无
暂无

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

相关问题 运行 Angular 应用程序时出现错误 - I am getting error while Running Angular application 在Angular 6应用程序中运行Bootstrap 4时遇到错误 - getting an error while running Bootstrap 4 with Angular 6 Application 当我尝试在我的 Angular 项目中添加引导程序时出现此错误 - I am getting this error when i try to add bootstrap in my Angular project 为什么在尝试将引导程序模板集成到角度应用程序时出现此错误? - Why am I having this error while trying to integrate a bootstrap template in an angular application? 我无法将引导程序包含在我的角度应用程序中 - I am unable include bootstrap into my angular application 在构建angular-6应用程序时出现此错误,我该如何解决呢? - While making a build of angular-6 application am getting this error how i can resolve this? 在我的angular2应用程序上运行npm install和ng serve时,出现以下错误 - I am getting an below error when i run npm install and ng serve on my angular2 application 尝试使用npm run start-ssr运行我的Angular时,控制台出现错误 - I am getting error in the console while trying to run my angular with npm run start-ssr 在我的 Angular 项目中包含引导样式时出错 - Getting Error while including a bootstrap Style to my Angular project 我正在学习 angular bootstrap,我正在尝试在我的机器上安装 npm。 它没有安装 - i am learning angular bootstrap, and i am trying to install npm on my machine. it is not getting installed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM