Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Angular does not throw exception for un-assigned bi-directional scope property #6060

Closed
dukehoops-zz opened this issue Jan 30, 2014 · 4 comments

Comments

@dukehoops-zz
Copy link
Contributor

please see demo - notice that foo is not assigned yet there is no exception in console. Per $compile docs exception should be raised, since foo is non-optional:

If the parent scope property doesn't exist, it will throw a NON_ASSIGNABLE_MODEL_EXPRESSION exception. You can avoid this behavior using =? or =?attr in order to flag the property as optional.

nice to have: IMO attributes should be treated in the same way: required unless ? is used

panuhorsmalahti added a commit to panuhorsmalahti/angular.js that referenced this issue Jan 30, 2014
Documentation states that NON_ASSIGNABLE_MODEL_EXPRESSION exception should be thrown if
a two-way attribute doesn't exist. This commit adds a simple test and throws an error
if the property is missing. Note that the documentation should probably be updated
and a different exception should be thrown using minErr.

This commit refers to issue angular#6060
@panuhorsmalahti
Copy link

My patch seems to fix the issue. However, docs/content/error/compile doesn't really have a suitable error message (and it looks like those should be preferred over the documentation's NON_ASSIGNABLE_MODEL_EXPRESSION).

@tbosch
Copy link
Contributor

tbosch commented Jan 31, 2014

Note that right now if the value in the isolate scope changes and there is no attribute, there is also a very obscure exception. Solving this issue would also prevent that case early on.

@btford btford removed the gh: issue label Aug 20, 2014
@IgorMinar IgorMinar modified the milestones: ng-fixit #1, 1.3.x Nov 24, 2014
panuhorsmalahti added a commit to panuhorsmalahti/angular.js that referenced this issue Nov 24, 2014
Documentation states that NON_ASSIGNABLE_MODEL_EXPRESSION exception should be thrown if
a two-way attribute doesn't exist. This commit adds a simple test and throws an error
if the property is missing. Note that the documentation should probably be updated
and a different exception should be thrown using minErr.

This commit refers to issue angular#6060
@petebacondarwin
Copy link
Contributor

There is a PR for this #6064

@petebacondarwin petebacondarwin modified the milestones: 1.3.x, ng-fixit #1 Nov 28, 2014
@lgalfaso lgalfaso removed their assignment Dec 16, 2014
@petebacondarwin petebacondarwin modified the milestones: ng-fixit #1, Backlog Sep 25, 2015
@Narretz
Copy link
Contributor

Narretz commented Jul 25, 2017

Further discussion here #16126

Closing as duplicate of #16126

@Narretz Narretz marked this as a duplicate of #6080 Jul 25, 2017
@Narretz Narretz closed this as completed Jul 25, 2017
@Narretz Narretz marked this as a duplicate of #6060 Jul 25, 2017
@Narretz Narretz marked this as a duplicate of #16126 Jul 25, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants