HTML:
<md-select placeholder="Type" required [(ngModel)]="request.type" (ngModelChange)="valueDateNeeded()">
<md-option *ngFor="let type of requestTypes" [value]="type.value">
{{type.name}}
</md-option>
</md-select>
我想获取所选选项的值。然后将它链接到valueDateNeeded(),以便我可以根据值设置true或false,然后我可以显示或不显示另一个div。
答案 0 :(得分:0)
您需要使用 <!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script type="text/javascript">
$( document ).ready(function() {
$( "#b1" ).on( "click", function() {
console.log('button click');
disen(this);
$.ajax({
url: "your_php_page.php",
method: "POST",
data: { key1 : "your_value1", key2 : "your_value2" },
dataType: "html",
success: function(data) {
$('#info').html(data);
},
error: function(jqXHR, textStatus, errorThrown) {
$('#info').html(textStatus + ", " + errorThrown);
},
complete: function() {
disen("#b1");
},
});
});
});
</script>
</head>
<body>
<span id="info"></span><br>
<input type="button" id="b1" value="test">
</body>
</html>
例如
component.ts
[(ngModel)]
component.html
public variableStore: any;
该值将在<select [(ngModel)]="variableStore">
<option value="1">1</option>
</select
答案 1 :(得分:0)
试试这个: - 的 component.html: - 强>
<md-select placeholder="Type" required [(ngModel)]="date" (ngModelChange)="valueDateNeeded($event)">
<md-option *ngFor="let type of requestTypes" [ngValue]="type.value">
{{type.name}}
</md-option>
</md-select>
<强> component.ts 强>
date:any;
更改您的[(ngModel)]名称,并在ts文件中将此名称声明为变量。