3

我没有 ngMock 的代码是'here'

var app = angular.module('logExample',[]);
app.controller('LogController', ['$scope', '$log', function($scope, $log) {
$scope.$log = $log;
$scope.message = 'Hello World!';
}]);

当我在需求的角度模块中添加 'ngMock' 时,控制器不会执行,请检查'here'

var app = angular.module('logExample',['ngMock']);
app.controller('LogController', ['$scope', '$log', function($scope, $log) {
$scope.$log = $log;
$scope.message = 'Hello World!';
}]);

有人可以告诉我是什么问题吗?我正在尝试使用角度模拟进行日志记录。我希望根据级别获取日志,即我想要一些方法来分别获取错误日志、警告日志等。

谢谢。

4

1 回答 1

3

That's because you are using ngMock module in the dependency list. To run apps with a mocked backend, you should include ngMockE2E.

ngMock is only used in unit tests, where you won't run the entire application, only a part of it.

See the app running here: http://plnkr.co/edit/l6PadUOdoip4obWXLflO?p=preview

于 2015-02-18T15:45:23.913 回答