Reputation: 10704
I have 2 variables. model
and _model
. Essentially, model is going to be the property that people would bind to with my template. When it binds, it will set _model
and then _model
will be used in the dart and in the markup for the form binding.
My question is this. I know in Dart, the underscore is a denotation of a private variable. i wasnt sure if it being private encompasses the scope of the markup associated with the Dart class.
That being said. It seems that when I set:
_model = new Model();
the class understands it just fine, but if I want to notify the markup using set by way of:
set("_model", new Model());
the class doesnt understand it. It is almost as if there are 2 different scopes of _model
. Maybe I can get by this by changing all references of _model
to something like componentModel
or something else which doesnt use an underscore at all.
Can someone explain this more clearly to me, because I think I am missing something when it comes to pre-pending an underscore and plausibly how set works.
Upvotes: 1
Views: 272
Reputation: 658263
Not sure what you expect from
_model = new Model();
This is normal code and expected to work.
set("_model", new Model());
needs to use reflection to set the value of the _model
property and I'm pretty sure this can't work because there is no way to access private fields from another library. There could be a way for a transformer to change the code (for example add public getters and setters) that would allow code to access private members. But as far as I remember, this is not the case.
Upvotes: 0