undefined不是一个对象(评估'$scope.students.pay')
undefined is not an object (evaluating '$scope.students.pay')
我有一个这样的测试:
it('calls the stuFun method', function () {
$scope.stuFun();
expect($scope.stuFun).to
.have.been.calledOnce;
expect($scope.students.pay).to.not.equal(null);
assert.isNotTrue($scope.students.pay)
});
以下是我的控制器功能:
$scope.stuFun = function() {
$scope.students.pay = false;
};
为什么我收到以下错误:
undefined is not an object (evaluating '$scope.students.pay')
解决方案附在下面:
it('calls the stuFun method', function () {
$scope.students = {};
$scope.stuFun();
expect($scope.stuFun).to
.have.been.calledOnce;
expect($scope.students.pay).to.not.equal(null);
assert.isNotTrue($scope.students.pay)
});
现在运行它,它应该可以工作。
相关文章:
- AngularJS:ng之后,重复$scope值未按预期更新
- $ionicplatform内的$scope不;不起作用
- 使用$scope方法时的ControllerAs语法
- 如何将ngrepeat下的ngmodel绑定到$scope
- 另一个if(!$scope.$$phase)$scope$apply()szenario-需要帮助才能通关
- 使用AngularJS Directive WHITOUT$scope创建一个动态html元素
- $scope变量被视为字符串AngularJs
- ng在更新$scope后重复不更新信息
- 正在获取Angular以检测$scope中的更改
- 如何惯用地手动销毁scope&在AngularJS中重新创建
- Understanding Javascript scope with "var that = this&qu
- AngularJS,angular.element($0).scope()揭示了每个控制器的函数
- Ng出口无法访问父$scope
- ng选项-用vm替换$scope
- $scope变量,ng隐藏/显示
- 强制 $scope.$watch 只开火一次
- Ionic:AngularJS变量未使用$scope更新DOM
- Angular$scope在模式窗口内不起作用
- 在将绑定应用于控制器之后,是否会发出Angular$scope事件
- undefined不是一个对象(评估'$scope.students.pay')