:{{producto.stock}}&lt; / span&gt; &LT; / H4&GT; &LT; p为H. {{producto.precio | 货币 </跨度> }}&LT; / p为H. &lt; img class =“img-responsive”ng-src =“{{producto.imagen}}”&gt; &lt; button’s(‘this.numColumnas’,function(){ this.filas = this.getFilas(this.productos,this.numColumnas); }); * /});var articulos = [{ nombre:’FUJIFILM FinePix S8600 - 黑人 - C谩mara fotogr谩fica 数字 </跨度> 鈥
我猜这个问题与此有关 this 没有提到你认为它在手表回调中的作用。如果你尝试绑定 this 变量,它有效吗?
this
var self = this; this.$watch('this.numColumnas', function() { self.filas = self.getFilas(self.productos, self.numColumnas); });
这种方式有效:
'use strict'; var app = angular.module('miTienda', []); app.controller('TiendaController', ['$scope', function($scope) { this.productos = articulos; ..... var self=this; $scope.$watch('tienda.numColumnas', function() { self.filas = self.getFilas(self.productos, self.numColumnas); });