📜  如何使用AngularJS获取单选按钮的值?

📅  最后修改于: 2021-05-13 19:25:49             🧑  作者: Mango

在本文中,我们将看到如何在AngularJS的帮助下获取单选按钮的值。在本文中,我们将使用ng-model获取选中的单选按钮的值。

示例1:在此示例中,所选值显示为带有警报。

HTML


  

    
      
    

  

    

        GeeksForGeeks     

          

        How to get the radio button          value in AngularJS     

          
        
            
                Male:                 
                Female :                 
                   
                             
        
    
  


HTML


  

    
  
    

  

    

        GeeksForGeeks     

          

        How to get the radio button          value in AngularJS     

          
        
            
                Male:                 
                Female :                 
                   
                             
               

Choosen Gender = {{selGender}}

        
    
  


输出:

  • 在单击按钮之前:

  • 单击按钮后:

示例2:在此示例中,所选值显示在

标记中。

的HTML



  

    
  
    

  

    

        GeeksForGeeks     

          

        How to get the radio button          value in AngularJS     

          
        
            
                Male:                 
                Female :                 
                   
                             
               

Choosen Gender = {{selGender}}

        
    
  

输出: