I所定義的具有樣品的角應用如下面
(function() {
angular.module("WatchApp", [])
.controller("WatchController", function ($scope) {
$scope.message = "hello";
});
}());
我有一個測試的情況下像下面
describe("WatchController", function() {
var $scope;
beforeEach(module("WatchApp"));
beforeEach(
inject(function (_$controller_) {
$scope: {};
controller: _$controller_("WatchController", {
$scope: $scope
});
}));
describe("Initialization", function() {
it("Should be truthy", function() {
expect(true).toBeTruthy();
})
})
});
我知道測試用例是不對,只是寫了看看配置是否正確,但總是給出如下錯誤:
PhantomJS 2.1.1 (Windows 7 0.0.0) WatchController Initialization Should be truthy FAILED
TypeError: undefined is not an object (evaluating '$scope.message = "hello"') (line 5)
C:/robin/Studies/Angularjs/ut/app/controllers/watchController.js:5:19
[native code]
[email protected]:/robin/Studies/Angularjs/ut/bower_components/angular/angular.js:4680:61
[email protected]:/robin/Studies/Angularjs/ut/bower_components/angular/angular.js:10130:39
C:/robin/Studies/Angularjs/ut/bower_components/angular-mocks/angular-mocks.js:2194:21
C:/robin/Studies/Angularjs/ut/test/controllers/watchControllerSpec.js:9:38
[email protected]:/robin/Studies/Angularjs/ut/bower_components/angular/angular.js:4665:24
[email protected]:/robin/Studies/Angularjs/ut/bower_components/angular-mocks/angular-mocks.js:2965:26
[email protected]:/robin/Studies/Angularjs/ut/bower_components/angular-mocks/angular-mocks.js:2931:28
C:/robin/Studies/Angularjs/ut/test/controllers/watchControllerSpec.js:7:15
global [email protected]:/robin/Studies/Angularjs/ut/test/controllers/watchControllerSpec.js:1:9
請讓我知道了什麼是問題
它拋出以下異常。 錯誤:[$ injector:unpr]未知的提供者:$ scopeProvider < - $ scope – robin
Woops,改變了上面的一些東西,給它一個去嗎? – mwild
同樣問題仍然 – robin