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

Conversation

pkozlowski-opensource
Copy link
Member

Fixes #9820

@@ -1164,6 +1164,23 @@ describe('parser', function() {
fn.assign(scope, 123);
expect(scope.a.b.c).toEqual(123);
}));

it('should create undefined objects in assignment expressions', inject(function($parse) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we already have a test for this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

surpassingly I can see only very limited number of tests for the assign:

describe('assignable', function() {

But maybe I'm not looking at the right place...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't check, I'd just be surprised if we didn't. More tests are always good though

@caitp
Copy link
Contributor

caitp commented Oct 30, 2014

I'm not sure how I feel about this --- I guess it's okay maybe, but I dunno. the patch looks fine though

@pkozlowski-opensource
Copy link
Member Author

Yeh, honestly I also don't know what to think about this one :-) I guess it can be useful in some cases but I'm just afraid that we are introducing some corner cases I can't see atm.

@lgalfaso
Copy link
Contributor

I am torn about this, the reason being that if you have

<input ng-model="model[0]"/>
<input ng-model="model.foo"/>

then depending on the order the user fills the fields, we end up with an array or an object.

With this in mind, I lean towards not merging this, but not strong enought to oppose it getting merge

@lgalfaso
Copy link
Contributor

Ah, I see that @pkozlowski-opensource already posted the same issue in the original report. Sorry for the noise

@pkozlowski-opensource
Copy link
Member Author

@lgalfaso yeh, this was exactly my first worry as well.

Anyway, I don't feel strongly about this one either way. Let's either merge this or close as "won't fix" - there is no point spending too much time on this one.

@caitp
Copy link
Contributor

caitp commented Oct 30, 2014

I kinda feel like we should shy away from assignment in expressions and get people to initialize their data --- is that too unrealistic? :(

@zgmnkv
Copy link
Contributor

zgmnkv commented Oct 31, 2014

Please look at my comment in #9820
Regarding manual initialization: it's not always easy, for example with nested arrays like model[0].prop.arrayProp[1].innerProp. We need to watch model changes to initialize arrayProp.

@lgalfaso
Copy link
Contributor

This issue was discussed and the agreement was to make this PR a wont fix

@lgalfaso lgalfaso closed this Nov 11, 2014
philjolly pushed a commit to philjolly/angular-formly that referenced this pull request Aug 19, 2016
angular. does not (and will not angular/angular.js#9850) properly
handle arrays in keys unless they have already been created in the model. This fix/feature adds a
separate parser for these circumstances and a formlyConfig.extras flag to control its use. The flag
is in place to minimize impact on current functionality of the setter.

This is in support of formly-js#706
kentcdodds pushed a commit to formly-js/angular-formly that referenced this pull request Sep 6, 2016
angular. does not (and will not angular/angular.js#9850) properly
handle arrays in keys unless they have already been created in the model. This fix/feature adds a
separate parser for these circumstances and a formlyConfig.extras flag to control its use. The flag
is in place to minimize impact on current functionality of the setter.

This is in support of #706
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

$parse().assign() for expression with numeric index creates object instead of array
5 participants