Home > Web Front-end > JS Tutorial > body text

How to get radio buttons in angularjs

php中世界最好的语言
Release: 2018-04-12 15:35:49
Original
1860 people have browsed it

This time I will bring you the method of getting the radio button in angularjs, and the attention to getting the radio button in angularjs What are the matters ? Below are actual cases, let’s take a look at them.

In the Html page, there are three radio buttons. The second "Important" option is selected by default. Set ng-checked="true" to select this option by default. However, when submitting the form, it prompts $scope. The level is undefinestate. Why is it undefine when it is clearly selected by default?

So, I tested it first: write the following code on the Html page:

   

               

    

 {{ level }}

    //显示单选按钮选中的value 

Copy after login

The first time the page is loaded, although the "Important" radio button is selected by default, the page does not display the value corresponding to the "Important" radio button,

Click the "Emergency" button, the value of the "Emergency" button will be displayed below,

It turns out that when the page is loaded, $scope.level is not assigned a value and has no initial value. Even if ng-checked="true", the default selected value is not displayed! Need to be set in js: $scope.level= "Important"; At this time, refresh the page and the value of the selected button will be displayed by default

I believe you have mastered it after reading the case in this article Method, for more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

readlineHow to read line by line Get and write the content

vue determines whether the input content has spaces

The above is the detailed content of How to get radio buttons in angularjs. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!