0

我想从下拉列表中显示/隐藏特定选项选择的 div。但是 div 一直处于隐藏状态。

 <select class="form-control" ng-model="Type">
                    <option>First</option>
                    <option>Second</option>
                    <option>Third</option>
                    <option>Forth</option>
                </select>

      <div ng-hide="Type==='First'">
      <label>Div Content</div>
      </div>
4

1 回答 1

0

为此目的,ng-switch 指令更适合。请在此处查看 jsfiddle

html:

<div ng-app="app">
    <div ng-controller="Ctrl">
        <select ng-model="selection" ng-options="item for item in items"></select>
        <hr/>
        <div class="animate-switch-container" ng-switch on="selection">
            <div ng-switch-when="first">First option</div>
            <div ng-switch-when="second">Second option</div>
            <div ng-switch-when="third">Third option</div>
            <div ng-switch-when="forth">Forth option</div>
            <div ng-switch-default>default</div>
        </div>
    </div>
</div>

JS:

var app = angular.module('app', []);

app.controller('Ctrl', function ($scope) {
    $scope.items = ['first', 'second', 'third', 'forth'];

});
于 2014-06-10T23:24:04.320 回答