{"action":"created","issue":{"url":"https://api.github.com/repos/mgcrea/angular-strap/issues/1025","labels_url":"https://api.github.com/repos/mgcrea/angular-strap/issues/1025/labels{/name}","comments_url":"https://api.github.com/repos/mgcrea/angular-strap/issues/1025/comments","events_url":"https://api.github.com/repos/mgcrea/angular-strap/issues/1025/events","html_url":"https://github.com/mgcrea/angular-strap/issues/1025","id":41610129,"number":1025,"title":"\"bs-radio\" element doesn't work well with attribute \"ng-value\" instead of \"value\".","user":{"login":"benliu723","id":1772367,"avatar_url":"https://avatars.githubusercontent.com/u/1772367?v=3","gravatar_id":"","url":"https://api.github.com/users/benliu723","html_url":"https://github.com/benliu723","followers_url":"https://api.github.com/users/benliu723/followers","following_url":"https://api.github.com/users/benliu723/following{/other_user}","gists_url":"https://api.github.com/users/benliu723/gists{/gist_id}","starred_url":"https://api.github.com/users/benliu723/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benliu723/subscriptions","organizations_url":"https://api.github.com/users/benliu723/orgs","repos_url":"https://api.github.com/users/benliu723/repos","events_url":"https://api.github.com/users/benliu723/events{/privacy}","received_events_url":"https://api.github.com/users/benliu723/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mgcrea/angular-strap/labels/directive-buttons","name":"directive-buttons","color":"444444"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2014-09-01T06:25:58Z","updated_at":"2015-04-13T22:23:41Z","closed_at":null,"body":"When I use attribute “ng-value” in a \"bs-radio\" element instead of attribute \"value\", the element with attribute \"bs-radio-group\" works wired like:\r\nwhen you click one of the radio in \"bs-radio group\" buttons, all of the radio buttons are selected with class \"active\".\r\n\r\nI dig into the code and debug the code in \"bsRadio\", things go wrong with getting the value of a \"bs-radio\" element. the detail is listed as followings.\r\n\r\n\"src/button/button.js\", line 140:\r\nvar value = constantValueRegExp.test(attr.value) ? scope.$eval(attr.value) : attr.value;\r\n\r\nhtml code:\r\n<div class=\"btn-group\" ng-model=\"button.radio\" bs-radio-group>\r\n\t\t\t  <label class=\"btn btn-default\"><input type=\"radio\" class=\"btn btn-default\" ng-value=\"0\"> First</label>\r\n\t\t\t  <label class=\"btn btn-default\"><input type=\"radio\" class=\"btn btn-default\" ng-value=\"1\"> Second</label>\r\n\t\t\t  <label class=\"btn btn-default\"><input type=\"radio\" class=\"btn btn-default\" ng-value=\"2\"> Third</label>\r\n</div>\r\n\r\nwhen I debug the code in runtime at this line, I found attr.value equals \"undefined\", which means value haven't been applied while link function is running.\r\n\r\nI set the priority of 'bs-radio' to 2, which is higher than 0. cause the priority of 'ng-value' is 0.\r\nso that the linking function of those two directive is running in a right order. but the attr.value is still be \"undefined\".\r\n\r\nI have no clue of what's wrong with it. \r\n\r\nand I find a final way to resolve \"ng-value\" problem, here is code of how to get the right value:\r\nvar value;\r\nif (attr.ngValue) {\r\n      value = scope.$eval(attr.ngValue);\r\n} else {\r\n     value = constantValueRegExp.test(attr.value) ? scope.$eval(attr.value) : attr.value;\r\n}\r\n\r\nProblem has been resloved by using this method.\r\n\r\nI want to know if this is the right concept with yours.\r\n\r\nLooking forward for your reply!"},"comment":{"url":"https://api.github.com/repos/mgcrea/angular-strap/issues/comments/92516742","html_url":"https://github.com/mgcrea/angular-strap/issues/1025#issuecomment-92516742","issue_url":"https://api.github.com/repos/mgcrea/angular-strap/issues/1025","id":92516742,"user":{"login":"JetFault","id":487245,"avatar_url":"https://avatars.githubusercontent.com/u/487245?v=3","gravatar_id":"","url":"https://api.github.com/users/JetFault","html_url":"https://github.com/JetFault","followers_url":"https://api.github.com/users/JetFault/followers","following_url":"https://api.github.com/users/JetFault/following{/other_user}","gists_url":"https://api.github.com/users/JetFault/gists{/gist_id}","starred_url":"https://api.github.com/users/JetFault/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JetFault/subscriptions","organizations_url":"https://api.github.com/users/JetFault/orgs","repos_url":"https://api.github.com/users/JetFault/repos","events_url":"https://api.github.com/users/JetFault/events{/privacy}","received_events_url":"https://api.github.com/users/JetFault/received_events","type":"User","site_admin":false},"created_at":"2015-04-13T22:23:40Z","updated_at":"2015-04-13T22:23:40Z","body":"+1 for this! Wouldn't this let value be things like objects and not only string, num, bool?"}}