angularjs - Angular: variable after $scope.? -
this question might seem bit strange. i'm trying create functions update database via angular , because i'm lazy function be
gettable('tablebame')
it select table (mysql) matching parameter , return it. didn't think issue untill noticed worked 1 table.
$scope.users = {}; var gettable = function(name) { httpfactory.setname(name); httpfactory.get(function(response) { $scope./* name inserted in function here */ = response; }); }; gettable("users");
i still had static name comment right now. have tried things doesn't work.
('$scope.' + name)
is there way bind return value 'response' $scope. + 'name'?
just use javascript's bracket syntax access property variable name. since $scope
object can use
httpfactory.get(function(response) { $scope[name] = response; });
Comments
Post a Comment