Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 将单选按钮更改为“否”时,跨度应以角度隐藏_Angularjs - Fatal编程技术网

Angularjs 将单选按钮更改为“否”时,跨度应以角度隐藏

Angularjs 将单选按钮更改为“否”时,跨度应以角度隐藏,angularjs,Angularjs,在angular中,如果我将单选按钮从“否”更改为“是”,则范围内容应隐藏。 我不知道如何参加这个活动 这是小提琴 对 不 团队规模 您的ans将非常有用。 谢谢您必须使用ng hide或ng show指令 比如说 HTML Angular已经定义了处理无线电输入的行为。您不必使用任何radioChecked功能,只需在输入上组合使用ng model和value: <input type="radio" ng-model="hasTeam" value=

在angular中,如果我将单选按钮从“否”更改为“是”,则范围内容应隐藏。 我不知道如何参加这个活动

这是小提琴


对
不
团队规模
您的ans将非常有用。
谢谢

您必须使用ng hide或ng show指令

比如说

HTML

Angular已经定义了处理无线电输入的行为。您不必使用任何
radioChecked
功能,只需在
输入上组合使用
ng model
value

<input type="radio"
       ng-model="hasTeam"
       value="true"/> - Yes

<input type="radio"
       ng-model="hasTeam"
       value="false"/> - No

<span ng-if="hasTeam">
  I'm showing only if yes is selected.
</span>
-是
-没有
我仅在选择“是”时显示。

也许你应该这样做。

meriadec它正在工作,但onload没有选择单选按钮,只有当我们选择它的工作时,你才能检查相同的链接,原因是什么?这是因为
hasTeam
在开始时没有定义,所以评估为
false
。您可以在控制器中初始化它(并使用
ng value
而不是
value
来使用布尔类型而不是字符串)。示例如下:
 <input type="radio" id="radios3" name="radiosgg" class="SwitchOn" value="true"  checked 
           ng-click="radioChecked()" ng-model="myvar" ng-hide="hideVar">
$Scope.hideVar = false;
$Scope.myvar = false;

$Scope.radioChecked= function () {
   $Scope.hideVar = true;  // Hide your checkbox
   ... dosomething... 
}
<input type="radio"
       ng-model="hasTeam"
       value="true"/> - Yes

<input type="radio"
       ng-model="hasTeam"
       value="false"/> - No

<span ng-if="hasTeam">
  I'm showing only if yes is selected.
</span>