My 5 cent after 5 minutes: no rendering for incomplete models?
See original GitHub issueThis post is from someone who spent 5 minutes with the framework, while using Angular.JS for every day work…
The very first (Hello World!
) example takes us to this jsFiddle example: https://jsfiddle.net/chrisvfritz/50wL7mdz/
The very first thing I did, I extended the template to be: {{message}} = {{extended}}
. And the view came up empty. Why is it empty, if I’m just extending a template that has some properties already defined in it?
It was only after I added property extended
into the model that I was able to see the proper view.
How come the entire model is ignored/skipped unless it is fully defined? This doesn’t make sense. Any complex view/template design starts by introducing elements one by one, many of which may be optional, and we cannot even see anything unless everythign has been defined.
This looks like the wrong approach.
Please don’t be too judgmental, I just wanted to share my impression after 5 minutes of playing with it, which I think still matters because this is how many newcomers are likely to percieve this framework.
Issue Analytics
- State:
- Created 7 years ago
- Comments:22 (11 by maintainers)
Top GitHub Comments
Yes this is different from Angular, and it is intentional. It is required to explicitly declare all root-level reactive properties upfront. This has a few benefits:
Your
data
serves as the schema of your component state. When maintaining it later, by looking at your component definition you are able to instantly see what properties are available. If you simply dynamically add new properties at random places, it would be a maintenance nightmare, like maintaining a database without a schema.This results in more predictable behavior, in particular when paired with type-checking systems.
It avoids excessive re-render that might be caused by adding root-level properties.
Finally, as a developer you should be able to choose what browser to develop in. If Chrome 44 is the only browser you can use at your job, that seems like a terrible decision on your companies part. Do all customers of your company use Chrome 44? Probably not.
Well, the reasoning can be explained as follows:
If we take all of this into account, it seems to me that it’s not worth our limited resources to try and hunt down a bug that is not reproducible for us, but may happen for 0.08% of users if someone pushed this wrong code to production.