1
페이지의 컨트롤러와 별도의 컨트롤러를 사용하는 AngularJS 지시문에 대한 단위 테스트를 작성하려고합니다. 그러나 테스트에서 해당 컨트롤러에 액세스 할 수있는 방법을 찾을 수 없습니다.자체 컨트롤러가있는 각도 명령 테스트
'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
액세스 할 수 있습니다 :
여기 내 지시인가? 또는 액세스 할 수 있도록 내 코드를 구조화하는 더 좋은 방법이 있습니까?