我的控制器中有下拉数据。
$scope.groups={{"gpId": 3, "name" :"Tom"}, {"gpId": 32, "name" :"Helen"},{"gpId": 9, "name" :"Amy"}
$scope.user=
{
tkId: 32;
place: NW
}
在我的html中,我有以下选择
<select ng-model="user.tkId" ng-options="a.gpId as a.name for a in groups track by a.gpId></select>
当我跑步时,我会选择Helen,但是当我想从下拉菜单中更改选择时,它不会让我失望。 请让我知道如何更改它以选择其他选项,以便我可以在需要时保存。谢谢
答案 0 :(得分:0)
以下代码段有效。
首先,像$('.btn').each(initDraggable);
function initDraggable() {
var param = {}
param.drag = drag
param.stop = stopper
param.start = startOsc
$(this).draggable(param)
}
var Variables = {}
Variables.Frequency = 0
function drag(myEvent, myUI) {
var Frequency = myUI.position.left + 100
var Duration = 5000
if (Math.abs(Variables.Frequency - Frequency) > 25) {
//You could put some validation on creation, but since you're not creating it, it's not necessary here
/*if (typeof(Variables.osc) === 'undefined') {
} else {
Variables.osc.stop(0)
}*/
Variables.Frequency = Frequency;
//Oscillator(Frequency,Duration)
Variables.osc.frequency.value = Frequency;
}
}
function startOsc(myEvent, myUI) {
var Frequency = myUI.position.left + 100
Oscillator(Frequency) //Since it plays in continue you don't need duration
}
function stopper() {
Variables.osc.stop(0)
}
Variables.ctx = new(window.AudioContext || window.webkitAudioContext)
function Oscillator(argFrequency /*,argDuration*/ ) {
Variables.osc = Variables.ctx.createOscillator()
Variables.osc.type = 0
Variables.osc.connect(Variables.ctx.destination)
Variables.osc.frequency.value = argFrequency
Variables.osc.start(0)
/*setTimeout(myTimeout,argDuration)
function myTimeout() {
Variables.osc.stop(0)
}*/
}
It's written in the angular docs <link rel="stylesheet" href="//cdn.jsdelivr.net/bootstrap/latest/css/bootstrap.css">
<link rel="stylesheet" href="//cdn.jsdelivr.net/jquery.ui/latest/jquery-ui.min.css">
<span class="btn btn-primary">Drag me</span>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="//cdn.jsdelivr.net/bootstrap/latest/js/bootstrap.js"></script>
<script src="//cdn.jsdelivr.net/jquery.ui/latest/jquery-ui.min.js"></script>
<script src="//cdn.jsdelivr.net/jquery.ui.touch-punch/latest/jquery.ui.touch-punch.js"></script>
和[{}, {}]
不应该一起使用。
请勿在同一表达式中使用
track by
和as
。它们并非旨在协同工作。
select as