我正在使用module().controller()
语法创建我的控制器。
angular.module('App', []);
angular.module('App').controller('PhoneListCtrl', ['$scope', function ($scope) {
'use strict';
$scope.phones = [
{
"name": "Nexus S",
"snippet": "Fast just got faster with Nexus S."
},
{
"name": "Motorola XOOM™ with Wi-Fi",
"snippet": "The Next, Next Generation tablet."
},
{
"name": "MOTOROLA XOOM™",
"snippet": "The Next, Next Generation tablet."
}
];
}]);
这很好用。但现在我想用茉莉花测试它,我的测试用
ReferenceError: AppController is not defined
.
我的测试:
/* jasmine specs for controllers go here */
describe('PhoneCat controllers', function () {
describe('PhoneListCtrl', function () {
it('should create "phones" model with 3 phones', function () {
var scope = {},
ctrl = new PhoneListCtrl(scope);
expect(scope.phones.length).toBe(3);
});
});
});
如果我将控制器更改为经典功能,测试工作正常。
我错过了什么?