javascript - $scope how to use variable in angular js -


i using angular js. below angular code

$scope.remove = function (index) {              var name = $scope.data.filters[index].filtername;                // value of name = 'aaaa' or 'bbbb' , on               $scope. data. filters. splice (index, 1);             $scope.json = angular.tojson($scope.data);         }; 

and html

<div><small>{{aaaa}}</small></div> <div><small>{{bbbb}}</small></div> <select class="bbbb"> <option> .... </select> <select class="aaaa"> <option> .... </select> 

based on value of name want reset {{ }} vale in view.

say example example

reset value of {{aaaa}} if name = aaaa

so how can use variable name below updated

var name = $scope.data.filters[index].filtername; $scope.name = "" /// how can  $(name).selectpicker('deselectall'); 

can me

thanks,

you should use bracket notation this. using can target property of object name stored in variable:

$scope[name] = ''; 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -