你好,我正在尝试从md-选项中获取值,例如:
<md-select name="state" ng-model="currentUser.state" ng-change="selectChanged()" required>
<md-option value="Test">Test</md-option>
<md-option value="Test2">Test2</md-option>
<md-option value="Test3">Test3</md-option>
</md-select>我想要
价值: Test3
$scope.selectChanged = function(){
if ($scope.currentUser.state=="Test3"){
$scope.curr_date = new Date();
}
};但这不是工作。如果选择的话,我如何获得值Test3来设置它。
发布于 2017-02-18 20:56:55
应该管用的。您正确地定义了控制器吗?我用你的代码做了一个小提琴 --它能工作。
请张贴完整的控制器代码以及。
angular.module('MyApp', ['ngMaterial'])
.controller('MyCtrl', function ($scope) {
$scope.currentUser = {};
$scope.currentUser.state = {};
$scope.selectChanged = function(){
if ($scope.currentUser.state=="Test3"){
alert('yay!');
}
};
})https://stackoverflow.com/questions/42320424
复制相似问题