Angularjs$范围函数修复?

Angularjs$范围函数修复?,angularjs,Angularjs,//单击一个单选按钮时,其他单选按钮的详细信息不应可见,反之亦然。但我的两个单选按钮的详细信息始终可见。 //我的输出始终显示hidedvd和hidebook分区。我一次只需要看到一个部分 HTML 您的代码在我创建的这个环境中工作得非常好。请确保您已将ngMaterial脚本添加到您的代码中,该脚本在您发布的代码中丢失 <script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.8/angular-mat

//单击一个单选按钮时,其他单选按钮的详细信息不应可见,反之亦然。但我的两个单选按钮的详细信息始终可见。 //我的输出始终显示hidedvd和hidebook分区。我一次只需要看到一个部分

HTML


您的代码在我创建的这个环境中工作得非常好。请确保您已将ngMaterial脚本添加到您的代码中,该脚本在您发布的代码中丢失

<script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.8/angular-material.min.js"></script>

Controller.js

 $scope.bookShow = false; 
 $scope.itemType = function(value) {   

 if(value=="book"){
    $scope.bookShow=true;
 }
 else {
    $scope.bookShow = false; 
 } 
}

HTML


添加新项目

DVD
书籍
ISBN:

标题:

//在这里换 扇区DVD:

出版日期:

作者:

出版商:

页数:

//在这里换 行业书籍:

语言:

字幕:

制作人:

演员:


删除2 ng更改、选中ng、itemType函数、hidebook变量,以及使用
ng if=“value==“book”
代替
ng hide=“hidedvd”
ng if=“value==“dvd”
代替
ng hide=“hidebook”
时会发生什么?
<script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.8/angular-material.min.js"></script>
 $scope.bookShow = false; 
 $scope.itemType = function(value) {   

 if(value=="book"){
    $scope.bookShow=true;
 }
 else {
    $scope.bookShow = false; 
 } 
}
 $scope.bookShow = false; 
 $scope.itemType = function() {   
 $scope.bookShow=!$scope.bookShow;
}
<form class="form" ng-controller="formCtrl">

    <h1 class="h1">Add a new Item</h1><br><br>
    <input type="radio" name="check" value="dvd"  ng-model="value" ng-checked="true"  ng-change='itemType(value)'>DVD<br>
    <input type="radio" name="check" value="book"  ng-model="value"  ng-change='itemType(value)'>Book<br>
    <fieldset>
    <p>ISBN:<br>
    <input type="text" name="ISBN" ng-model="itemInput1" tabindex="1" required autofocus><br>
    Title:<br>
    <input type="text" name="Title" ng-model="itemInput2" tabindex="2" required><br>
    </p>
    </fieldset> 
   //CHANGED HERE
    <div  ng-show=!bookShow>   
    <fieldset>
    <p>Sector DVD:<br> 
    <input type="text" name="Sector" ng-model="itemInput3" tabindex="3"><br>
    Publication Date:<br>
    <input type="text" name="Published" ng-model="itemInput4" tabindex="4"><br>
    Authors:<br> 
    <input type="text" name="Authors" ng-model="itemInput5" tabindex="5"><br>
    Publishers:<br> 
    <input type="text" name="Publishers" ng-model="itemInput6" tabindex="6"><br>
    Page Count:<br> 
    <input type="text" name="Pages" ng-model="itemInput7" tabindex="7"><br></p>
    </fieldset>
    </div>
    //CHANGED HERE
    <div ng-show=bookShow>
    <fieldset>
    <p>Sector BOOK:<br> 
    <input type="text" name="Sector" ng-model="itemInput8" tabindex="3"><br>
    Languages:<br>
    <input type="text" name="Languages" ng-model="itemInput9" tabindex="4"><br>
    Subtitles:<br> 
    <input type="text" name="Subtitles" ng-model="itemInput10" tabindex="5"><br>
    Producers:<br> 
    <input type="text" name="Producers" ng-model="itemInput11" tabindex="6"><br>
    Actors:<br> 
    <input type="text" name="Actors" ng-model="itemInput12" tabindex="7"><br></p>
    </fieldset>
    </div>


    <input class="submit-button" type="submit" name="AddBook" value="Add" />

</form>