ng-checked and ng-change radio button not work together - angularjs

前端 未结 4 2065
梦谈多话
梦谈多话 2020-12-16 17:37

http://plnkr.co/edit/RP9SpO1qGjn5Ua6pZJ3D?p=preview

js

angular.module(\"sampleapp\", []).controller(\'samplecontroller\', function($scope,$rootScope)         


        
4条回答
  •  感动是毒
    2020-12-16 18:34

    The ng-change directive requires the ng-model directive to be present.

    From the Docs:

    ngChange

    Note, this directive requires ngModel to be present.

    — AngularJS ng-change Directive API Reference


    The ng-model and ng-checked directives should not be used together

    From the Docs:

    ngChecked

    Sets the checked attribute on the element, if the expression inside ngChecked is truthy.

    Note that this directive should not be used together with ngModel, as this can lead to unexpected behavior.

    — AngularJS ng-checked Directive API Reference

    Instead set the desired initial value from the controller.

    For more information, see

    • AngularJS input[radio] Directive API Reference

提交回复
热议问题