问题标签 [ng2-bootstrap]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
typescript - 导入 ng2-bootstrap 会改变我的 tsc 输出目录结构
我有以下文件夹结构
我已经tsc
配置为输出,dist/js
所以运行后npm run tsc
我有以下内容:
经过一番努力,我设法融入ng-bootstrap
了我的项目。
如果我import
来自ng2-bootstrap
我的应用程序的某个地方,例如:
import { ACCORDION_DIRECTIVES } from 'ng2-bootstrap/components/accordion';
并将npm run tsc
我的文件夹结构更改为:
为什么会这样?
我包括:<script src="/vendor/ng2-bootstrap/bundles/ng2-bootstrap.js"></script>
在我的index.html
我可以用 angular2 做到这一点
<script src="/vendor/angular2/bundles/angular2.dev.js"></script>
,
import {Component} from 'angular2/core'
并且这不会创建dist/js/node_modules/angular2
文件夹
更新
这是我的 tsconfig.json 的内容
datepicker - ng2-boostrap datePicker 似乎覆盖了 ngModel
我正在使用 ng2-bootstrap datePicker,无论是未定义初始值,还是使用 initDate,都会出现意外行为。在加载页面时立即绑定到指令的 ngModel 的变量,在我的例子中:
[(ngModel)]="campaign.startDate"
campaign.startDate 记录为:
FIRST - 今天,或者如果我在 ngOnInit 中任意设置它的分配值
THEN - 一旦我的请求返回一个新值,就会采用我分配的值
THEN - 今天
我不知道是什么触发了第三步,据我所知,它不是来自我的代码,而是由于 2 方式绑定,datePicker 本身出于某种原因为其分配了“今天”的值
TS
和 HTML
angularjs - Visual Studio 2015 中的 ng2-bootstrap 模块
我正在尝试在 VS 项目中导入 ng2-bootstrap 模块。我获取了这个 github repo并在添加"moment": "2.11.2"
到tsconfig.json
.
在 VS 中我做的几乎一样,添加"ng2-bootstrap": "1.0.5", "moment": "2.11.2"
到tsconfig.json
, VS 恢复到Dependencies
. 然后,gulp
我移动ng2-bootstrap.min.js, moment.js
到根应用程序目录并将其捆绑到system.js 配置中index.html
并moment.js
映射为map: { moment: 'libs/moment.js }
.
将警报组件添加到我的 angular 后class
:
构建后出现以下错误:
我将它<script src="libs/moment.js"></script>
插入我的并在likeindex.html
中声明一个变量,错误消失了,但是在 bulding bootstrap之后没有任何效果。date-formatter.ts
declare var moment: any
tags
并且以一种神秘的方式,我被编译node_modules/ng2-bootstrap
并且我的所有ts
文件都在wwwroot/app/scripts
目录中。我替换了编译的js
文件wwwroot/app/
,它也没有效果。我的应用程序看不到ng2-bootstrap
组件的本机属性。也许有人面临这种问题?
angular - Angular 2 - Bootstrap (Ng2-Bootstrap) 预输入实现
我正在尝试实现NG2-Bootstrap 预输入但没有成功。
这是我的代码:
上面的代码与 ng2-bootstrap 页面的示例页面基本相同。
我看不到结果。页面卡在“正在加载”中并抛出此异常:
我想知道:这就是一切吗?也许我错过了什么?
angular - 角2。例外:在警报上找不到指令注释
我的浏览器日志中出现以下异常:
在警报中找不到指令注释
堆栈跟踪:
如何解决?
核心库:
- 角 2
- Angular 2 引导程序
构建系统:
这是我的源代码:
Angular 2 引导程序“alert.component.ts”
这部分代码属于ng2-bootstrap框架。
我的项目 App 组件
引导脚本
引导脚本的完整源代码在这里
我的 tsconfig.json
Webpack 加载器:
包.json
打字.json
javascript - 如何在 Karma 中配置 System.js 以测试依赖于 moment.js 的代码
如果我的应用程序代码使用取决于 moment.js 库的 ng2-boostrap 模块,我将无法在 Karma 中运行 jasmine 测试。
该应用程序在浏览器中运行良好,并且可以在浏览器中运行 jasmine 测试,方法是向系统添加即时映射:
我尝试在 karma.shim 内部进行相同的操作,但它不起作用。我正进入(状态:
在我的 karma.conf 我有
在 karma-test-shim 中:
映射部分的工作原理取决于我放在那里的内容,moment
我稍后会在 XHR 错误路径中得到它。
完整的文件可以在简单的测试项目中找到: https ://github.com/tzielins/angular-start-project
业力配置基于http://twofuckingdevelopers.com/2016/01/testing-angular-2-with-karma-and-jasmine/
我很高兴使用更简单的配置,但是我很幸运能够从头开始使用 System.js/Karma,而且这个没有 ng2-boostrap 依赖项也可以工作(测试中的代码仅从 ng2-boostrap 导入,这足以消除业力,可以将其注释掉以使测试通过)。
我必须从 System.js 配置中遗漏一些明显的东西。
rest - 如何将 ng2-bootstrap Typahead 与 REST 后端一起使用
如何使用 REST 服务作为 Typescript 中的源进行预输入?我需要使用 promise 还是可以使用 observables?具体来说,我正在从 ng2-bootstrap 主页的示例中的 getAsyncData() 函数中寻找我需要的东西。
休息响应:
我所拥有的(不起作用):
主页.ts
主页.html
angular - ng2-bootstrap 在 angular2 beta 11 中不起作用
我正在使用 ng2-bootstrap,它在 angular2 beta 9 中运行良好。今天我已将 angular2 更新到 beta 11 版本。现在我面临这个问题
如何解决这个问题?
angular - Angular 2 错误:SyntaxError: Unexpected token <
我知道这个问题被问了大约 100 次,但我收到了这个错误。请检查屏幕截图。
错误:SyntaxError: Unexpected token < at Object.eval ( http://localhost:3000/node_modules/ng2-bootstrap/components/datepicker/date-formatter.js:2:14 ) at eval ( http://localhost:3000 /node_modules/ng2-bootstrap/components/datepicker/date-formatter.js:13:4 ) 评估http://localhost:3000/moment 评估http://localhost:3000/node_modules/ng2-bootstrap/components/datepicker/ date-formatter.js 评估http://localhost:3000/node_modules/ng2-bootstrap/components/datepicker/datepicker-inner.js 评估http://localhost:3000/node_modules/ng2-bootstrap/components/datepicker/datepicker。 js 评估http://localhost:3000/node_modules/ng2-bootstrap/components/datepicker/datepicker-popup.js 评估http://localhost:3000/node_modules/ng2-bootstrap/components/datepicker.js 评估http://localhost: 3000/node_modules/ng2-bootstrap/ng2-bootstrap.js 加载http://localhost:3000/app/main.js 时出错
我遵循了为修复系统配置而给出的解决方案
但是在这个解决方案之后我收到错误并且页面没有加载......
任何人都知道要遵循的步骤然后请告诉我。