Javascript HTML中的范围变量未获取其值
不要担心Javascript HTML中的范围变量未获取其值,javascript,angularjs,Javascript,Angularjs,不要担心gallery.photos和photo指令。我的问题是,当加载DOM而不是0时,计数器没有值为什么?和如何修复它以使其从控制器读取值?控制器中的$scope在哪里?您需要在控制器中添加$scope.counter=0而不是此,任何附加到$scope的内容都可以从视图中读取。控制器中的$scope在哪里?您需要在控制器中添加$scope.counter=0,而不是此,任何附加到$scope的内容都可以从视图中读取。您可以使用 (function() { angular .mo
gallery.photos和photo指令
。我的问题是,当加载DOM而不是0时,计数器没有值为什么?和如何修复它以使其从控制器读取值?控制器中的$scope在哪里?您需要在控制器中添加$scope.counter=0而不是此,任何附加到$scope的内容都可以从视图中读取。控制器中的$scope在哪里?您需要在控制器中添加$scope.counter=0,而不是此,任何附加到$scope的内容都可以从视图中读取。您可以使用
(function() {
angular
.module('myapp')
.controller('GalleryController', GalleryController);
GalleryController.$inject = ['GalleryService'];
function GalleryController(GalleryService){
var self=this;
self.counter=0;
}
})();
你可以打电话给柜台
(function() {
angular
.module('myapp')
.controller('GalleryController', GalleryController);
GalleryController.$inject = ['GalleryService'];
function GalleryController(GalleryService){
var self=this;
self.counter=0;
}
})();
您必须以
库的形式访问它。计数器
,因为您没有将计数器添加到$scope
,而是添加到控制器的此
非常感谢您,您必须以库的形式访问它。计数器
,因为您没有将计数器添加到$scope
,但是对于管制员的这个
非常感谢你,伙计
gallery.counter