2017-07-04 56 views
1

我一直無法找到使用下拉菜單中的對象數組使用角度下拉的示例,有人可以幫我調試嗎?我最終希望「顯示我」是角庫中的一個單選按鈕列表。顯示基於角度下拉對象數組的內容

<div ng-app="myApp" ng-controller="myCtrl"> 
     Method: 
     <select ng-model="selectedName" ng-options="x.name for x in names"> 
     </select> 
    </div> 

    <script> 
     var app = angular.module('myApp', []); 
     app.controller('myCtrl', function($scope) { 
      $scope.names = [{name: 'Experiment'}, {name: 'Clinical Trial'}, {name: 'Case Report'}]; 
       $scope.changeme = function() { 
       alert('here'); 
       } 
     }); 
    </script> 
    <div ng-if = "x.name == 'Experiment'"> 
     <span>Show Me</span> 
    </div> 
+0

對不起,不完全跟隨此 - 會在哪裏下拉菜單去?你談論下拉,但是然後說你想要一個廣播組。你能澄清嗎?最終,我想你會想看看ng-repeat標籤,但是你對上述問題的回答將幫助我們爲你調試它:https://docs.angularjs.org/api/ng/指令/ ngRepeat –

+0

你好,所以我想有一個下拉菜單,一旦你選擇了一個選項,一系列單選按鈕就會以下拉菜單的形式出現 – kam329

回答

0

工作版本

<div ng-app="myApp" ng-controller="myCtrl"> 
    Method: 
    <select ng-model="selectedName" ng-options="name.name as 
     name.name for name in names"> 
    </select> 

<div ng-if = "selectedName === 'Experiment'"> 
    <span>Show Me</span> 
</div> 
     </div> 
<script> 
    var app = angular.module('myApp', []); 
    app.controller('myCtrl', function($scope) { 
    $scope.selectedName = null; 
     $scope.names = [{name: 'Experiment'}, {name: 'Clinical Trial'}, {name: 'Case Report'}]; 

    }); 
</script> 

Plunker

你的問題是,你把你的 「讓我看看」 外塊NG-應用