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

radio Input does not set checked if model is boolean and value is used #7971

Closed
Narretz opened this issue Jun 24, 2014 · 2 comments
Closed

Comments

@Narretz
Copy link
Contributor

Narretz commented Jun 24, 2014

See this test:

it('should set the view if model is boolean', function() {
  compileInput(
      '<input type="radio" ng-model="value" value="true" />' +
      '<input type="radio" ng-model="value" value="false" />');

  scope.$apply(function() {
    scope.value = true;
  });

  expect(inputElm[0].checked).toBe(true);
  expect(inputElm[1].checked).toBe(false);
});
@Narretz Narretz added this to the Backlog milestone Jun 24, 2014
@ewinslow
Copy link
Contributor

Does it work if you do scope.value = "true"

@tbosch
Copy link
Contributor

tbosch commented Aug 4, 2014

Hi,
using ng-value="true" works, or as @ewinslow suggested, scope.value="true".
The point is that <input> always interprets the value attribute as a string.

See this plunker: http://plnkr.co/edit/Q0W7pl9yYUMrhqVMvzRJ?p=preview

So this works as expected, but we could optimize the docs for ngValue and input[type=checkbox]. PRs welcome!

@btford btford removed the gh: issue label Aug 20, 2014
@IgorMinar IgorMinar modified the milestones: ng-fixit #1, Backlog Nov 24, 2014
@Narretz Narretz assigned Narretz and unassigned lgalfaso Jun 15, 2015
netman92 pushed a commit to netman92/angular.js that referenced this issue Aug 8, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.