我有一个AngularJS指令,它从它的属性中读取输入数据,如下所示:
<my-directive input-data='items'></my-directive>
我的指示:
return {
scope: {
inputData: '='
}
}
...
现在,我通常在我的范围内定义一个嵌套的对象数组,该指令从我的范围读取数据,但现在我正在尝试使用我的指令很好地使用jasmine,grunt和angular,这样我就可以测试它,但是我收到了这个错误:
Error: [$compile:nonassign] Expression 'undefined' used with directive 'angularMultiSelect' is non-assignable!
这就是我试图在茉莉花测试中注入数据的方法:
inject(function($compile, $rootScope) {
scope = $rootScope.$new();
//scope.items = []; //<--- this works, but it's useless
scope.items = [{}, {}]; //<---- this triggers the error (I haven't deleted anything, that is an array with 2 empty objects
elem = angular.element(html);
$compile(elem)(scope);
scope.$digest();
});
我应该如何将我的数据从jasmine传递到我的指令?
答案 0 :(得分:0)
我的问题是该指令试图将另一个模型数据绑定到jasmine范围内的非现有变量。