问题标签 [angular-require]

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.

0 投票
1 回答
654 浏览

angularjs - Basic Integration angular js and require js not working

It's seem to be easy but trust me i wasted almost my 4 hours on it still didn't find out what is wrong in it. Very simple setup install everything with bower like require angular domReady bootstrap fontawesome..etc.

Sorry if I forgot to add something this is my first setup angular with require.

It is showing me two errors:-

1) ReferenceError: require is not defined

//this error is in rconfig.js

2) ReferenceError: define is not defined //this error is in require.js itself

main.js

rconfig.js

Angular version AngularJS v1.3.13

Any help would be appretiated.

UPDATE suggested by @irysius

If i change define to require in my main.js then there are 2 errors:-

1)TypeError: path.match is not a function paths = path.match(MODULE_SPLITER), //in the require.js file

2) ReferenceError: require is not defined

//this error is in rconfig.js

0 投票
1 回答
555 浏览

angularjs-directive - ng-describe/Angular/Karma 单元测试:使用 ng-describe 的 setupControllers 编译带有所需控制器的指令

我正在使用ng-describe(我必须说,很棒)为 angularJS 编写业力单元测试。

我有两个指令。我想测试testing需要somethingController.

code:

如果我使用手动编译,我能够成功运行这些测试。

如果我不进行手动编译,最终会出现以下错误:

我真正想做的是:

我正在尝试最大限度地使用 ng-describe 并摆脱手动编译。我试过使用describeApi.setupControllershttps://github.com/kensho/ng-describe#secondary-options我没有运气。

  • 使用 adescribeApi.setupElement('<testing></testing>')会给我留下上面显示的 $compile 错误。
  • 使用describeApi.setupControllers('something')给我留下了错误:Error: [ng:areq] Argument 'something' is not a function, got undefined
  • 我试图设置名为something, somethingController,的控制器$something$somethingController但我也在undefined, not a function那里看到了错误。

有没有办法让这个工作?目前我无法在网上找到解决方案...

0 投票
0 回答
322 浏览

angularjs - 使用 require 测试指令时出现 $compile:ctreq 错误

我正在使用 Karma 测试一个非常简单的指令:

它在 HTML 页面中工作,但使用业力我得到以下错误:

错误:[$compile:ctreq] 指令“b”所需的控制器“a”找不到!

在业力/茉莉花测试中使用以下代码:

有任何想法吗 ?

以下是完整文件:

业力.conf.js

指令.js

指令.spec.js

0 投票
1 回答
122 浏览

angularjs - 错误:[$compile:ctreq] 数据在来自不同模块的两个指令之间传递

我有两个不同的模块,其中有两个指令。我需要在这两个指令之间传递数据。我使用需要属性。但我得到了一些错误

我的第一个指令是

在 YearsortController 我有代码

在我的第二个指令中,我有代码

0 投票
1 回答
1136 浏览

javascript - 需要角度输入文件

我有一个 div,它根据列表包含一个或多个输入文件。这是使用 ngFor 生成的。我使用两个按钮删除或添加列表元素,当然它会更新 HTML。

这是html:

然后在我的组件中:

这工作正常。我使用 papaparse 读取文件并将其添加到 datasetList。但是,我的问题是我无法在输入文件中添加“必需”。但就我所阅读的内容而言,它似乎不存在。

因此,我添加了一个变量“fileValid”来检查文件是否被正确选择。如果文件被正确解析,此变量将初始化为 false 并更改为 true。然后,如果用户添加文件,此变量将变为 false。但是,当用户删除 div 时,我不知道如何管理。例如:

  • 如果我有 3 个 div 用于输入文件,其中两个没有选择文件。用户可以删除其中之一,变量“fileValid”应该仍然为假。
  • 如果我有 2 个 div 用于输入文件并且其中一个被选中而另一个未被选中。如果用户删除了未选中的那一项,则变量“fileValid”应该为真。

我怎么能管理它?或者还有其他方法吗?

0 投票
1 回答
439 浏览

typescript - 找不到 require 但已经在 Angular 中全局安装和配置了 @types/node

我是 Angular 的新手,刚刚尝试为google maps autocomplete创建我的第一个指令。但是我在directive.ts 文件中遇到了问题。在顶部,我有一个找不到的要求,因此无法构建应用程序。

const google = require('@types/googlemaps');

错误消息说

src/app/_directives/google-places.directive.ts(2,16) 中的错误:错误 TS2580:找不到名称“需要”。您需要为节点安装类型定义吗?尝试npm i @types/node然后添加node到 tsconfig.xml 中的类型字段。

所以我查看了我的 package.json 文件中的“@types/node”,我看到了。

然后我查看了 tsconfig.json 的类型,没有看到,所以我添加了它。

然后我进行了重建,但仍然找不到“要求”,因此构建失败。

只是为了获得更多信息,这里是指令文件。Intellisense 建议我将“要求”转换为导入,所以我这样做了,但这似乎也没有解决它。