我为自定义dropdown创建了一个html.html下面的路径是“partials / institutions / coordinatorDropdown.html”
<div class="dropdown" ng-click="toggleDropDown">
<button class="form-control overflow" type="button" id="dropdownMenu-list" data-toggle="dropdown" name="datatype" id="datatype" ng-required="true" ng-class="{ 'selected-class-name': $index == selectedIndex }" ng-model="coordinator.role" ng-bind="coordinator.role" required>
</button>
<ul class="dropdown-menu dropdown-menu-list" role="menu" aria-labelledby="dropdownMenu-list" ng-init="toggleDropDown = true" ng-show="toggleDropDown" >
<li role="presentation" ng-repeat="item in role" value="{{ item.roleid }}" ng-click="changeCoordinatorType(item.value, $index)">
<span ng-class="{ 'dropdown-selected-item': $index == selectedIndex }">{{ item.coordinator_type }}</span>
</li>
</ul>
</div>
在我原来的html中,我使用的如下:
<div class="col-md-6">
<div class="error-message">
<span ng-show="addCoordinatorForm.coordinatorType.$error.required && !addCoordinatorForm.coordinatorType.$pristine"
class="errormessage" ng-bind="'Please select a coordinator type.'"></span>
</div>
<div name="coordinatorType" ng-include="'partials/institutions/coordinatorDropdown.html'"></div>
</div>
现在在我的控制器中,
我需要检查$ scope.coordinator.role值是否已更改。
当我给出
时,在我的控制器中if ($scope.addCoordinatorForm.$dirty){
}
检查其他控件但未更改下拉列值。
有人可以为我建议一个解决方案吗?。