出于某种原因,无论选择哪个选项,一旦触摸该字段,该字段始终被标记为无效。
HTML:
<md-input-container class="md-block">
<label>Select</label>
<md-select flex
id="mySelect"
ng-model="myModel.mySelect"
ng-change="myCallback()"
placeholder="Select"
required>
<md-option ng-repeat="option in options | orderBy:'option.name'"
ng-value="option.id">
{{option.name}}
</md-option>
</md-select>
</md-input-container>
控制器:
.controller( 'myController', function ( $scope, $mdDialog, myModel ) {
$scope.options = [{name: "option1", id:1},{name:"option2", id:2},{name: "option3", id:3}];
$scope.isModified = false;
$scope.myModel = angular.copy(myModel);
$scope.save = function ( model ) {
$mdDialog.hide( angular.copy( model ) );
};
$scope.myCallback = () => $scope.isModified = !angular.equals(myModel, $scope.myModel);
})