This is the wrong forum for this question because angular has nothing to do
with it.
AngularJS builds on JavaScript, so you should learn that first.
Anyway: The answer depends on the scope of $x.
If it is global (and you are in a browser environment):
$x = "Car";
window[$x] = "Mercedes";
If you are talking about local variables in a function:
function foo() {
var $x = "Car";
}
then no, I don't think it is possible.
The JS way would be
function foo() {
var holder = {
x: "Car"
};
holder[holder.x] = "Mercedes";
// holder.Car => "Mercedes"
}
On Sunday, July 13, 2014 11:42:09 AM UTC+2, CoderBoy wrote:
>
> In PHP you can do something like this
>
> $x="Car";
> $$x="Mercedes";
> echo $Car;
>
> O/P : Mercedes.
>
> AFAIK I figured this thing is called reflection. So in GWT you can do
> these kind of stuff somewhat differently.
>
> I am wondering can we do the same in AngularJS either directly on
> indirectly using some modules?
> Is it impossible what I am talking about?
>
>
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.