<script>
$("#point-range").ionRangeSlider({
min: 0,
max: 10,
from: 1,
from_min: 1,
from_max: 10,
step: 1,
grid: true,
hide_min_max: true,
onFinish: function (data) {
$('#point-value').val(data.from);
}
});
</script>
如何在调用ng-model
函数时为onFinish
设置值。我尝试将值设置为隐藏输入:
onFinish: function (data) {
$('#point-value').val(data.from);
}
{{ Form::hidden('point', null, ['ng-model' => 'evaluationData.point', 'id' => 'point-value']) }}
但是当我提交表单时,我不会evaluationData.point
。
答案 0 :(得分:2)
尝试将该脚本包装在指令中。
angular.module('myApp').directive('myDirective', function() {
return {
scope: 'ngModel',
link: function(scope, element, attrs) {
$("#point-range").ionRangeSlider({
min: 0,
max: 10,
from: 1,
from_min: 1,
from_max: 10,
step: 1,
grid: true,
hide_min_max: true,
onFinish: function (data) {
$('#point-value').val(data.from);
scope.ngModel = 'Blah';
scope.$digest();
}
});
}
}
})