我正在尝试使用 Karma 为 AngularJS 指令编写单元测试。为了能够在测试中使用指令模板,我使用了karma-ng-html2js-preprocessor。
对于以下模板 HTML,我在单元测试中收到 Lexer 错误消息,但在实际系统中一切正常。
<div class="test"
ng-style="{width: vm.width,
height: vm.height,
'margin-left': vm.x,
'margin-top': vm.y}">
</div>
错误信息:
错误:[$parse:lexerr] Lexer Error: Unexpected next character at column 17-17 [] in expression [{width: vm.width,\n' + ' height: vm.height,\n' + ' \'margin -left\': vm.x,\n' + '\'margin-top\': vm.y}]。
这是预处理器中的错误还是我的表达有问题?