Is this safe? Or will this be vulnerable to code injections?
$scope.placeholder = function(value, def) {
var val = eval("$rootScope.master.user." + value);
if (val) {
return val;
} else {
return def;
}
};
I was using bracket notation, but I realized I could not if I passed in an object such as Address.addr1 in the example below:
<input type="email" ng-model="user.email" placeholder="{{placeholder('email', 'Email...')}}" /><br/>
<input type="text" ng-model="user.Address.addr1" placeholder="{{placeholder('Address.addr1', 'Addr. Line 1...')}}" />
I thought this might answer my question, but I wasn't sure: Is using javascript eval() safe for simple calculations in inputs?