angular.js icon indicating copy to clipboard operation
angular.js copied to clipboard

ng:change broken on 10.5

Open ProLoser opened this issue 14 years ago • 12 comments

Unless I'm just not using the proper syntax?

http://jsfiddle.net/ProLoser/TeU4Y/

ProLoser avatar Dec 16 '11 08:12 ProLoser

The link given for the code is invalid. Results in HTTP 404.

narisipalli avatar Dec 28 '11 23:12 narisipalli

Thought I might have hit this myself, but got a very simple example working easily: http://jsfiddle.net/pants/pGgCG/ If I can reproduce anything possibly broken I'll update the ticket, and maybe Dean ("ProLoser") can do the same.

lanterndev avatar Jan 11 '12 00:01 lanterndev

(One weird thing in my example is initially neither radio button is checked, even though their ng:model's both point at the same boolean field, and one's value is {{true}} and the other's is {{false}}. It corrects itself once you click one of them. Is this a bug?)

lanterndev avatar Jan 11 '12 03:01 lanterndev

works for me: http://jsfiddle.net/IgorMinar/pGgCG/14/

IgorMinar avatar Mar 21 '12 20:03 IgorMinar

@IgorMinar Yours exhibits the same behavior. The "not bar" radio button is not selected initially, despite having its "value" attribute match the value of the model variable it's bound to. (Maybe this belongs in a separate issue?)

lanterndev avatar Mar 21 '12 20:03 lanterndev

@pants: false !== 'false'

Wrap the value in quotes, the value defined in the view is considered a string.

Sent via Hubroid

ProLoser avatar Mar 21 '12 21:03 ProLoser

@pants we don't initialize the model from the "value" attr. this is a tough decision we made in 0.10.x, there has been some discussion about it on the mailing list recently with a proposed 3rd party directive that initializes the model.

IgorMinar avatar Mar 21 '12 22:03 IgorMinar

@IgorMinar Thanks for the reply. The fiddle in question isn't trying to initialize the model via the "value" attr; it's happy to initialize bar in the controller. It's just trying to get the currently selected radio button to be in sync with the model from the start. Based on http://jsfiddle.net/vojtajina/MkwNu/2/ it looks like this should be possible, no? Is there no way to modify your http://jsfiddle.net/IgorMinar/pGgCG/14/ to fix this?

I looked on the mailing list for the thread you're referring to and couldn't find it. If you could link to it, I'd love to catch up on it.

Can you confirm whether @ProLoser's comment is true? I would think {{false}} would not be turned into 'false'.

Sorry to derail this ticket. Happy to move discussion elsewhere if appropriate.

lanterndev avatar Mar 21 '12 22:03 lanterndev

@pants: I talked with @vojtajina and he's currently working on a fix that will address these the input[type=radio] issues.

the current limitation is that radio buttons can be bound only to models of type string, so if in your fiddle you change the link in the controller that assigns scope.bar = false to scope.bar = 'false' then the radio button will be initialized properly. this is silly and we think we know how to address it.

@vojtajina do we have a issue for this radio button change? can you post it here?

IgorMinar avatar Mar 21 '12 23:03 IgorMinar

@pants the mailing list thread was discussing something unrelated.

IgorMinar avatar Mar 21 '12 23:03 IgorMinar

Thanks @IgorMinar, the 'false' hack indeed "fixed" it: http://jsfiddle.net/pGgCG/24/. Looking forward to following your progress.

lanterndev avatar Mar 21 '12 23:03 lanterndev

Here is the issue #816

vojtajina avatar Mar 21 '12 23:03 vojtajina