1

我有这个尝试使用 ng-show 的基本示例。如果从国家下拉框中选择了“GB”,我实际上只想显示页面的一部分。当我从下拉框中选择 GB 时,我已验证 ctrl 在其中收到“GB”。但是,这些元素最初并未隐藏在页面上,从选择框中选择内容没有任何影响。我会很感激任何帮助。

<ng-form name="directorsForm" cc-pitch-form="5" ng-controller="work.myCtrl as ctrl">
    <div class="row cc-form__group">
        <div class="columns large-3">
            <label>Country</label>
        </div>
        <div class="columns large-3 left">
            <select ng-options="country.code as country.name for country in ctrl.countryList" ng-model="ctrl.selectedCountry" />
        </div>
    </div>

    <div ng-show="ctrl.selectedCountry =='GB'">
        <div class="columns large-3">
            <label>Enter address</label>
        </div>
    </div>
</ng-form>
4

1 回答 1

0

替换这一行

<select ng-options="country.code as country.name for country in ctrl.countryList" ng-model="ctrl.selectedCountry" />

像这样

<select ng-options="country.code as country.name for country in ctrl.countryList" ng-model="ctrl.selectedCountry" ></select>

选择中的自我关闭不适用于角度我希望它有所帮助!

于 2017-08-17T12:04:48.803 回答