我正在尝试为某些输入设置默认值,它适用于所有其他输入,但我遇到了复选框和滑块的问题。 (在需要时将它们设置为检查)
这是我的控制者:
App.controller('EmailAlertController', function($rootScope, $scope, $stateParams, $http, $timeout)
{
var ID = $stateParams.ID;
$http.get('ajax/email_alerts/view_email_alert.php?ID='+ID).then(function (results)
{
$scope.EmailAlert = results.data
});
});
这是view_email_alert.php:
$EmailAlerts = array();
if (isset($_GET['ID']) && intval($_GET['ID']) > 0)
{
$ID = $_GET['ID'];
$EmailAlerts = EmailAlerts::getById($ID);
}
echo json_encode($EmailAlerts);
结果如下:
{"ID":"9539","AppRef":"7418","PriceMin":"439900","PriceMax":"789800","Type":"House","SubType":"Detached House","Rooms":"4","Area":"City","SubArea":"Town","Terms":"Fixed Price","SearchGroupName":"name","DTRecv":"2014-12-08 23:02:15.440","DTCreated":"12-08-2014 06:36","Name":"Name Example","Email":"email@email.com","Protection":"Protected"}
我的HTML:
<input type="checkbox" name="Terms" id="Terms" ng-model="EmailAlert.Terms" value="{{EmailAlert.Terms}}" ng-checked="EmailAlert.Terms=='Fixed Price'" ng-true-value="Fixed Price" ng-false-value=""> {{EmailAlert.Terms}}
var min = $('#PriceRange').val().split(";")[0];
var max = $('#PriceRange').val().split(";")[1];
$("#PriceRange").ionRangeSlider({
min: 0,
max: 1000000,
from: min,
to: max,
type: 'double',
step: 100,
prefix: "£",
prettify: false,
hasGrid: true
});