Javascript $scope:scope在angularjs中是什么意思
我正在学习Angularjs的官方教程,我被困在第二步 这里有一个片段,我不理解Javascript $scope:scope在angularjs中是什么意思,javascript,angularjs,Javascript,Angularjs,我正在学习Angularjs的官方教程,我被困在第二步 这里有一个片段,我不理解$scope:scope的含义 describe('PhoneListCtrl', function(){ beforeEach(module('phonecatApp')); it('should create "phones" model with 3 phones', inject(function($controller) { var scope = {}, ctrl =
$scope:scope
的含义
describe('PhoneListCtrl', function(){
beforeEach(module('phonecatApp'));
it('should create "phones" model with 3 phones', inject(function($controller) {
var scope = {},
ctrl = $controller('PhoneListCtrl', {$scope:scope});
expect(scope.phones.length).toBe(3);
}));
});
我猜它是一个键值对,但是作用域被初始化为
{}
,为什么它的成员元素是phones
?有人能解释一下这是什么意思吗?你在写测试。这一行:
ctrl = $controller('PhoneListCtrl', {$scope:scope});
将作用域作为空对象注入到实际控制器中。您的测试确保控制器在示波器上设置长度为3的phones
属性