我试图为一个指令编写测试,所以我用$编译手工构造它。 (是的,我知道我可以使用e2e测试,但在这种情况下,我想测试一些DOM独立的逻辑,所以我使用单元测试方法。)
原文链接:https://www.f2er.com/angularjs/144196.html我有一个我与范围绑定的字段:{foo:’=’}。当我尝试根据指令的范围设置它,我得到以下错误:
Error: Non-assignable model expression: undefined (directive: foo) at Error (<anonymous>) at $get.parentSet (https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js:4146:25) at Object.<anonymous> (https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js:4160:23) at Object.$get.Scope.$digest (https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js:7693:38) at Object.$get.Scope.$apply (https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js:7894:24) at SNAKE_CASE_REGEXP (https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js:930:13) at Object.invoke (https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js:2788:25) at bootstrap (https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js:928:12) at angularInit (https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js:904:5) at https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js:14397:5
转载于fiddle。