2
在我的測試中,我創建了手角控制器製造$scope
:
beforeEach(function() {
inject(function($controller, $rootScope) {
$scope = $rootScope.$new();
controller = $controller('ContentController', {$scope: $scope});
});
});
是否有必要每次打電話試運行後$scope.$destroy()
?
afterEach(function() {
$scope.$destroy();
});
我從來沒有做過,測試是短暫反正。除非您想要檢查$ destroy事件的某些事件處理程序。 – Chandermani 2015-04-04 13:42:31