hi i'm trying to create $scope dynamically and set it true on click to show some details inside ng-repeat but it doesn't seem to work ,Here is the plunk plunk
var app=angular.module('myApp',[]);
app.controller('myCtrl', function($scope){
$scope.details=[{
cid:100,
foo:'first component'
},
{
cid:101,
foo:'second component'
},{
cid:102,
foo:'third component'
}];
$scope.showGraph=function(serverid){
console.log(serverid);
if ($scope[serverid] === undefined) {
$scope[serverid] = true;
console.log($scope[serverid]);
} else {
$scope[serverid] = true;
}
};
});
thanks for your help.Any other suggestions to achieve this is also welcomed.
ng-ifshows fundamental javascript misunderstanding of dynamic variable names ... String + variable returns string not variable