javascript - $scope.$watch with a complex variable -



javascript - $scope.$watch with a complex variable -

i need $scope.$watch variable this:

$scope.data.localization[$scope.locale].properties[0].value

$scope.data.localization[$scope.locale].properties array of objects each object has code , value, utilize these couples create dynamic forms:

<input type="text" ng-repeat="property in $scope.data.localization[$scope.locale].properties" ng-model="property.value" />

now, textbox must visible if textbox has value, wanted $scope.$watch 1 of values doesn't work, callback of $watch never fired:

$scope.$watch("data.localization." + $scope.locale +".properties[0].value", function () { //show/hide texbox if have value });

any thought how implement that?

edit: tried

$scope.$watch("data.localization", function () { //show/hide texbox if have value });

and fires callback, looks problem dynamic property $scope.locale don't know how avoid that.

the problem if watch whole array, don't know value changed.

try this:

var mywatcher = "data.localization." + $scope.locale +".properties[0].value"; $scope.$watch(mywatcher, function () { //show/hide texbox if have value });

javascript angularjs angularjs-scope angularjs-ng-repeat

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -