AngularJs中指令的单元测试
在AngularJs中测试指令时出错: 索引大小错误:索引大小错误:DOM异常1(第14925行)AngularJs中指令的单元测试,angularjs,unit-testing,Angularjs,Unit Testing,在AngularJs中测试指令时出错: 索引大小错误:索引大小错误:DOM异常1(第14925行) 错误:索引大小错误:DOM异常1 代码: 谢谢。真有趣,我在回答我自己的问题。 由于指令错误而引发错误 <tf-progress-indicator progress='"indeterminate"' size="small" style="position:relative; top:3px " ></tf-progress-indicator> 因为它需要一个.
错误:索引大小错误:DOM异常1 代码:
谢谢。真有趣,我在回答我自己的问题。 由于指令错误而引发错误
<tf-progress-indicator progress='"indeterminate"' size="small" style="position:relative; top:3px " ></tf-progress-indicator>
因为它需要一个.gif图像。
只是有点小毛病。
在测试指令pub工具栏时,我们可以模拟tf progress indicator指令,这样就永远不会调用它
下面的代码用于模拟direcitve:
beforeEach( module( 'yourModule', function( $compileProvider ) {
$compileProvider.directive( 'nameOfDirectiveToMock', function() {
var def = {
priority: 100,
terminal: true,
restrict:'E',
template:'<div ></div>'
};
return def;
} );
} ) );
beforeach(模块('yourModule',函数($compileProvider){
$compileProvider.directive('nameOfDirectiveToMock',function(){
变量定义={
优先:100,
终端:是的,
限制:'E',
模板:“”
};
返回def;
} );
} ) );
我回答自己的问题真的很有趣。
由于指令错误而引发错误
<tf-progress-indicator progress='"indeterminate"' size="small" style="position:relative; top:3px " ></tf-progress-indicator>
因为它需要一个.gif图像。
只是有点小毛病。
在测试指令pub工具栏时,我们可以模拟tf progress indicator指令,这样就永远不会调用它
下面的代码用于模拟direcitve:
beforeEach( module( 'yourModule', function( $compileProvider ) {
$compileProvider.directive( 'nameOfDirectiveToMock', function() {
var def = {
priority: 100,
terminal: true,
restrict:'E',
template:'<div ></div>'
};
return def;
} );
} ) );
beforeach(模块('yourModule',函数($compileProvider){
$compileProvider.directive('nameOfDirectiveToMock',function(){
变量定义={
优先:100,
终端:是的,
限制:'E',
模板:“”
};
返回def;
} );
} ) );
你能发布你的指令代码吗?我已经添加了指令代码。过来看。调试后,我知道需要加载.gif图像,这可能就是原因。删除后效果很好。你能发布你的指令代码吗?我已经添加了指令代码。过来看。调试后,我知道需要加载.gif图像,这可能就是原因。拆下后工作正常。
beforeEach( module( 'yourModule', function( $compileProvider ) {
$compileProvider.directive( 'nameOfDirectiveToMock', function() {
var def = {
priority: 100,
terminal: true,
restrict:'E',
template:'<div ></div>'
};
return def;
} );
} ) );