1
我正在尝试为AngularJS指令编写单元测试,该指令使用页面上的单独控制器。但是,我无法从我的测试中找到任何访问该控制器的方法。用他们自己的控制器测试Angular指令
这里是我的指令:
'use strict';
angular.module('myapp.directives')
.directive('searchButton', function() {
function SearchButtonCtrl ($scope, $location) {
$scope.search = function() {
$location.path('/search');
$location.search(q, $scope.query.w);
};
}
return {
template: '<input type="text" ng-model="query.q">',
controller: SearchButtonCtrl,
restrict: 'E'
};
});
是否有可能访问SearchButtonCtrl
?还是有更好的方法来构建我的代码,以便可以访问它?