0
我在我的指令控制器中有一个函数,我试图测试并找不到任何资源。我在之前的各如何测试指令控制器功能?
before each {
scope = $rootScope ;
$compile(element)(scope);
scope.$digest();
}
it('should update days when datepicker is changed', function() {
scope.seldate = new Date('4/11/2014');
scope.stdate = new Date('4/1/2014');
scop`enter code here`e.days = 10;
scope.$digest();
scope.$apply(function() {
scope.seldate = new Date('4/12/2014');
scope.datePickerChange(); // This is a function in my directive controller
});
expect(scope.days).toBe(11);
});
app.directive('mydirective',function(){
return {
restrict:'E',
scope:{
days: '=',
selectedDate: '=',
startDate: '='
},
$scope.datePickerChange = function() {
//Sod is helper for start of the day with hours/mins/seconds set to 0
$scope.days = moment(new Date($scope.selectedDate)).sod().diff($scope.getStartDate(), 'days');
};
};
});
这是抛出一个错误类型错误:对象#有没有方法“datePickerChange”