You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 2, 2020. It is now read-only.
Repository navigation
This repository was archived by the owner on Nov 2, 2020. It is now read-only.
This is because AngularJS stores some hidden values with the $-prefix. But it would certainly be possible to prefix all our stuff with, say, _ (so that $asdf is encoded as _$asdf) and then go back and forth between these representations. Pull requests are welcome :)
Well the only bulletproof (and relatively painless), to deal with problem in my opnion, is not use object structure as model, but create a special model for working with json. E.g after json is parsed, object is not passed into the scope, but is transformed to the following form:
If you pass such model into scope, it doesn't matter which keys angular adds later, because you interested only in specific keys. You can use also some escaping, but i believe it is way too error prone.
What's so error prone about this: prefixing each key with a _ when reading from the text area, removing the first char (i.e. the _) when writing back from the Angular model to the textarea.
Well I think it is simply cleaner, since you don't have to always remember that correct keys should have '_' prefix (at least you have to add it in key name editor/render, may be there some other places).
But the is definitely choice is yours, I'm just suggesting since I had to do something similar in the past, tried to use escaping at first, then I said screw it, and just implemented using special model structure and in the end it was much easier.
Activity
mb21 commentedon Sep 17, 2013
This is because AngularJS stores some hidden values with the
$-prefix. But it would certainly be possible to prefix all our stuff with, say,_(so that$asdfis encoded as_$asdf) and then go back and forth between these representations. Pull requests are welcome :)jusio commentedon Sep 17, 2013
Well the only bulletproof (and relatively painless), to deal with problem in my opnion, is not use object structure as model, but create a special model for working with json. E.g after json is parsed, object is not passed into the scope, but is transformed to the following form:
Such model corresponds to the following JSON
If you pass such model into scope, it doesn't matter which keys angular adds later, because you interested only in specific keys. You can use also some escaping, but i believe it is way too error prone.
mb21 commentedon Sep 17, 2013
What's so error prone about this: prefixing each key with a
_when reading from the text area, removing the first char (i.e. the_) when writing back from the Angular model to the textarea.jusio commentedon Sep 17, 2013
Well I think it is simply cleaner, since you don't have to always remember that correct keys should have '_' prefix (at least you have to add it in key name editor/render, may be there some other places).
But the is definitely choice is yours, I'm just suggesting since I had to do something similar in the past, tried to use escaping at first, then I said screw it, and just implemented using special model structure and in the end it was much easier.