- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 AngularJS 和 Bootstrap 开发网络应用程序。在我的应用程序中,主仪表板上有一个 Bootstrap 模式。此模式显示在切换按钮上。在主仪表板中有一些图表和网格。用于绘制这些图表和网格的输入字段来自该模态。
这是主仪表板 html。
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title></title>
<!-- angularJS scripts -->
<script
src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.js"></script>
<script src="../mvc/constants/constants.js"></script>
<script src="../mvc/service/Service.js"></script>
<script src="../mvc/controller/DashboardController.js"></script>
<link rel="stylesheet"
href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css">
<!-- KENDO scripts for creating charts -->
<script
src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body ng-controller="DashboardController" ng-init="initModal()">
<div id="mainContainer">
<div class="demo-section k-content wide">
<div class="col-xs-8">
<h1 style="padding-left: 15px">
HotelName<i class="fa fa-pencil-square-o"
style="color: #6789DA; cursor: pointer; position: relative; top: -10px; font-size: 27px;"
data-toggle="modal" data-target="#hotelDetailModal"></i>
</h1>
<h5 style="padding-left: 15px">{{packageString}}</h5>
<h5 style="padding-left: 15px">{{requestRoomTypeName}}</h5>
</div>
<div class="col-xs-4">
<!-- ng-click="initialMethod()" -->
<h4 style="text-align: right; margin-top: 14px; margin-right: 20px;">{{algoName}}
</h4>
<h6 style="padding-right: 20px; float: right">{{startDateString}}
{{endDateString}}</h6>
<!-- <button type="submit" class="btn btn-default"
style="margin-right: 20px; margin-bottom: 20px; margin-top: 2px; float: right;"
data-toggle="modal" data-target="#changeSearch"
ng-click="initialMethod()">Edit criteria</button> -->
</div>
<!-- </div> -->
</div>
<div class="col-md-12">
<div id="grid" class="demo-section k-content wide"></div>
</div>
<div id="example" class="col-md-12">
<div class="demo-section k-content wide">
<div id="chart"></div>
</div>
</div>
<div id="chartContainer" class="col-md-7">
<div id="competitorPriceChart"></div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="hotelDetailModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h1>Hotel Details</h1>
</div>
<div class="modal-body">
<div class="row">
<div class="col-xs-6">
<label>Schema Type</label> <select
class="form-control" required="required"
ng-model="schemaType"
ng-change="changeSchemaType()">
<option value="0">Hotel</option>
<option value="1">Destination</option>
</select>
</div>
<div class=col-xs-6>
<label>Sub Type</label> <select
class="form-control" id="subType"
ng-options="sub_type.cityCode for sub_type in subTypeList"
ng-model="subType" required="required"
ng-change="getHotelDataByDestination()"
value="{{sub_type.cityName}}">
<option value="" disabled selected hidden=true>Select
Option
</option>
</select>
</div>
</div>
<div class="row">
<div class="col-xs-4">
<label>Hotel</label>
</div>
<div class="col-xs-12">
<select class="form-control"
ng-options="hotel.hotelName for hotel in hotelList"
ng-model="hotel" required="required"
value="{{hotel}}"
ng-change="getRoomTypeByHotelName();getMealPlanByHotelName();">
<option value="" disabled selected hidden=true>Select
Option
</option>
</select>
</div>
</div>
<div class="row">
<div class="col-xs-6">
<label>Room Type</label> <select
class="form-control"
ng-options="roomType.roomTypeName for roomType in roomTypeList"
ng-model="roomType" required="required"
value="{{roomType}}">
<option value="" disabled selected hidden=true>Select
Option
</option>
</select>
</div>
<div class="col-xs-6">
<label>Meal Plan</label> <select
class="form-control"
ng-options="mealPlan.description for mealPlan in mealPlanList"
ng-model="mealPlan" required="required"
value="{{mealPlan}}">
<option value="" disabled selected hidden=true>Select
Option
</option>
</select>
</div>
</div>
<div class="row">
<div class="col-xs-3">
<label>Rooms</label>
<input id="rooms"
class="form-control" required="required"
ng-model="rooms"
type="number"/>
</select>
</div>
<div class="col-xs-3">
<label>Adults</label>
<input id="adults"
class="form-control" required="required"
ng-model="adults"
type="number"/>
</select>
</div>
<div class="col-xs-3">
<label>Children</label>
<input id="kids"
class="form-control" required="required"
ng-model="kids"
type="number"/>
</select>
</div>
<div class="col-md-3">
<label>Nights</label>
<input id="nights"
class="form-control" required="required"
ng-model="nights"
type="number"/>
</div>
</div>
<div class="row">
<div class="col-xs-6">
<label style="margin: 15px 0">Departure Date</label> <input
type="date" class="form-control"
ng-model="departureDate">
</div>
</div>
<!-- <div class="row">
<div class="col-xs-6">
<button ng-click="detailCtrlViewModel.submit()"
class="btn btn-default" style="float: right;">Next</button>
</div>
</div> -->
</div>
<div class="modal-footer">
<button ng-click="submit()"
class="btn btn-primary" style="float: right;"
data-dismiss="modal">SUBMIT
</button>
</div>
</div>
</div>
</div>
当应用程序运行时,它应该显示包含所有图表和网格的主页。即,当页面加载时,输入应该有默认值。
模态正文字段(下拉菜单)正在从数据库中填充。
我的DashboardController如下。
var myApp = angular.module('myApp', ['DataService']);
myApp.controller('DashboardController', function ($scope, DataService) {
$scope.rooms = 1;
$scope.adults = 1;
$scope.kids = 0;
$scope.nights = 7;
$scope.departureDate = new Date();
$scope.schemaType = 1;
$scope.caclulateOn = new Date().toISOString().slice(0, 10);
$scope.initModal = function () {
console.log('initModal');
$scope.changeSchemaType();
$scope.getHotelDataByDestination();
};
$scope.changeSchemaType = function () {
$scope.subTypeList = [];
if ($scope.schemaType == "0") {
$scope.subTypeList.push({
cityName : "5 star",
cityCode : "city1",
}, {
cityName : "4 star or above",
cityCode : "city2",
});
$scope.subType = $scope.subTypeList[0];
} else {
$scope.subTypeList.push({cityCode:"CITY1",cityName:"CITY1"},{cityCode:"city2",cityName:"city2"});
$scope.subType = $scope.subTypeList[0];
console.log($scope.subType);
}
}
$scope.getHotelDataByDestination = function () {
console.log($scope.subType);
console.log($scope.subType.cityCode);
var destinationCode = $scope.subType.cityCode;
DataService.getHotelByDestinationService(destinationCode).success(
function(data) {
$scope.hotelList = [];
for (var k = 0; k < data.length; k++) {
$scope.hotelList.push({hotelId: data[k].hotelId, hotelName:data[k].hotelName });
}
if(destinationCode == "CITY1"){
$scope.hotel = $scope.hotelList[17];
console.log($scope.hotel);
}else if(destinationCode == "CITY2"){
$scope.hotel = $scope.hotelList[2];
console.log($scope.hotel);
}else {
$scope.hotel = $scope.hotelList[0];
}
$scope.getRoomTypeByHotelName();
$scope.getMealPlanByHotelName();
}).error(function(error) {
console.log(error)
});
}
$scope.getRoomTypeByHotelName = function () {
console.log($scope.hotel);
var hotelName = $scope.hotel.hotelName;
DataService.getRoomTypeByHotelNameService(hotelName).success(
function(data) {
$scope.roomTypeList = [];
for (var k = 0; k < data.length; k++) {
$scope.roomTypeList.push({roomTypeName: data[k].roomTypeName });
}
$scope.roomType = $scope.roomTypeList[0];
}).error(function(error) {
console.log(error)
});
}
$scope.getMealPlanByHotelName = function () {
var hotelName = $scope.hotel.hotelName;
DataService.getMealPlanByHotelNameService(hotelName).success(
function(data) {
console.log(data)
$scope.mealPlanList= [];
for (var k = 0; k < data.length; k++) {
$scope.mealPlanList.push({code: data[k].code, description: data[k].description });
}
$scope.mealPlan = $scope.mealPlanList[0];
}).error(function(error) {
console.log(error)
});
}
$scope.submit = function () {
console.log('submit');
console.log($scope.rooms);
console.log($scope.adults);
console.log($scope.kids);
console.log($scope.nights);
console.log($scope.departureDate);
console.log($scope.hotel);
console.log($scope.roomType);
console.log($scope.mealPlan);
// call function to draw charts and grid
$scope.displayTableView($scope.hotel.hotelId, $scope.roomType.roomTypeName, $scope.departureDate, $scope.nights,
$scope.mealPlan.code);
$scope.initCompetitorPriceChart($scope.hotel.hotelId, $scope.departureDate, $scope.nights, $scope.mealPlan.code);
}
});
当页面加载时,它调用 initModal 函数并填充模式中的所有下拉字段。但实际上我得到一个空白页面,我切换模式我可以选择字段并单击提交按钮,然后绘制图表。最初它不绘制任何图形或网格。我真正想要的是显示带有图表的主页,这些图表应该为默认输入字段绘制(当模式加载默认值时,默认值是下拉列表中的第一个元素)。同样,一旦我从模式中选择新值并提交,它应该使用基于新选择值的新图表重新加载主页。
希望您清楚我在说什么。任何建议将不胜感激。
已更新
这是
之后的响应DataService.getHotelByDestinationService(destinationCode).success(
function(data) {}
[{"hotelId":26047,"hotelCode":null,"hotelName":"Anahita Residence and Villas","rating":null,"cityCode":null,"holidayId":27751},{"hotelId":26341,"hotelCode":null,"hotelName":"Belle Mare Plage (Hotel CONSTANCE)","rating":null,"cityCode":null,"holidayId":27911},{"hotelId":26364,"hotelCode":null,"hotelName":"Blumarine Attitude Hotel","rating":null,"cityCode":null,"holidayId":27874},{"hotelId":26362,"hotelCode":null,"hotelName":"Friday Attitude Hotel","rating":null,"cityCode":null,"holidayId":27873},{"hotelId":26965,"hotelCode":null,"hotelName":"Heritage Awali","rating":null,"cityCode":null,"holidayId":27934},{"hotelId":26963,"hotelCode":null,"hotelName":"Heritage le Telfair","rating":null,"cityCode":null,"holidayId":27931},{"hotelId":26306,"hotelCode":null,"hotelName":"Hotel Angsana Balaclava Mauritius","rating":null,"cityCode":null,"holidayId":27971},{"hotelId":26046,"hotelCode":null,"hotelName":"Hotel Sofitel So Mauritius","rating":null,"cityCode":null,"holidayId":27752},{"hotelId":26301,"hotelCode":null,"hotelName":"Long Beach Resort","rating":null,"cityCode":null,"holidayId":27753},{"hotelId":26763,"hotelCode":null,"hotelName":"LUX* Belle Mare","rating":null,"cityCode":null,"holidayId":27914},{"hotelId":26762,"hotelCode":null,"hotelName":"LUX* Grand Gaube","rating":null,"cityCode":null,"holidayId":27913},{"hotelId":26761,"hotelCode":null,"hotelName":"LUX* Le Morne","rating":null,"cityCode":null,"holidayId":27892},{"hotelId":26721,"hotelCode":null,"hotelName":"Maradiva Villas Resort & Spa","rating":null,"cityCode":null,"holidayId":27891},{"hotelId":26330,"hotelCode":null,"hotelName":"Mont Choisy Beach Villas","rating":null,"cityCode":null,"holidayId":27932},{"hotelId":26331,"hotelCode":null,"hotelName":"Mystik Apart Hotel","rating":null,"cityCode":null,"holidayId":27933},{"hotelId":26048,"hotelCode":null,"hotelName":"One and Only Le Saint Geran","rating":null,"cityCode":null,"holidayId":27791},{"hotelId":26328,"hotelCode":null,"hotelName":"Preskil Beach Resort","rating":null,"cityCode":null,"holidayId":27771},{"hotelId":26361,"hotelCode":null,"hotelName":"Recif Attitude Hotel","rating":null,"cityCode":null,"holidayId":27872},{"hotelId":26329,"hotelCode":null,"hotelName":"Solana Beach Resort","rating":null,"cityCode":null,"holidayId":27792},{"hotelId":26743,"hotelCode":null,"hotelName":"Tamassa All-Inclusive Resort","rating":null,"cityCode":null,"holidayId":27893},{"hotelId":26541,"hotelCode":null,"hotelName":"The Ravenala Attitude Hotel","rating":null,"cityCode":null,"holidayId":27871},{"hotelId":26821,"hotelCode":null,"hotelName":"The Saint Regis Mauritius Resort","rating":null,"cityCode":null,"holidayId":27936},{"hotelId":26053,"hotelCode":null,"hotelName":"The Sands Suites Resort and Spa","rating":null,"cityCode":null,"holidayId":27772},{"hotelId":26822,"hotelCode":null,"hotelName":"The Westin Turtle Bay Resort & Spa","rating":null,"cityCode":null,"holidayId":27935},{"hotelId":26764,"hotelCode":null,"hotelName":"Villas de LUX* Belle Mare","rating":null,"cityCode":null,"holidayId":27912},{"hotelId":26363,"hotelCode":null,"hotelName":"Zilwa Attitude Hotel","rating":null,"cityCode":null,"holidayId":27875}]
谢谢
最佳答案
要在页面加载期间显示图表,您应该预填充图表所需的值。
之后,运行渲染图表的函数。
问候,马利凯
代码:
$scope.initModal = function () {
console.log('initModal');
$scope.changeSchemaType();
$scope.getHotelDataByDestination();
preselectChartValues();
updateCharts();
};
function preselectChartValues() {
$scope.hotel = {}; // some hotel
$scope.roomType = {} // some room type
// ...
}
function updateCharts() {
$scope.displayTableView(
$scope.hotel.hotelId,
$scope.roomType.roomTypeName,
$scope.departureDate,
$scope.nights,
$scope.mealPlan.code);
$scope.initCompetitorPriceChart(
$scope.hotel.hotelId,
$scope.departureDate,
$scope.nights,
$scope.mealPlan.code);
}
关于javascript - AngularJS:在页面初始加载时设置默认输入值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38115526/
SQLite、Content provider 和 Shared Preference 之间的所有已知区别。 但我想知道什么时候需要根据情况使用 SQLite 或 Content Provider 或
警告:我正在使用一个我无法完全控制的后端,所以我正在努力解决 Backbone 中的一些注意事项,这些注意事项可能在其他地方更好地解决......不幸的是,我别无选择,只能在这里处理它们! 所以,我的
我一整天都在挣扎。我的预输入搜索表达式与远程 json 数据完美配合。但是当我尝试使用相同的 json 数据作为预取数据时,建议为空。点击第一个标志后,我收到预定义消息“无法找到任何内容...”,结果
我正在制作一个模拟 NHL 选秀彩票的程序,其中屏幕右侧应该有一个 JTextField,并且在左侧绘制弹跳的选秀球。我创建了一个名为 Ball 的类,它实现了 Runnable,并在我的主 Draf
这个问题已经有答案了: How can I calculate a time span in Java and format the output? (18 个回答) 已关闭 9 年前。 这是我的代码
我有一个 ASP.NET Web API 应用程序在我的本地 IIS 实例上运行。 Web 应用程序配置有 CORS。我调用的 Web API 方法类似于: [POST("/API/{foo}/{ba
我将用户输入的时间和日期作为: DatePicker dp = (DatePicker) findViewById(R.id.datePicker); TimePicker tp = (TimePic
放宽“邻居”的标准是否足够,或者是否有其他标准行动可以采取? 最佳答案 如果所有相邻解决方案都是 Tabu,则听起来您的 Tabu 列表的大小太长或您的释放策略太严格。一个好的 Tabu 列表长度是
我正在阅读来自 cppreference 的代码示例: #include #include #include #include template void print_queue(T& q)
我快疯了,我试图理解工具提示的行为,但没有成功。 1. 第一个问题是当我尝试通过插件(按钮 1)在点击事件中使用它时 -> 如果您转到 Fiddle,您会在“内容”内看到该函数' 每次点击都会调用该属
我在功能组件中有以下代码: const [ folder, setFolder ] = useState([]); const folderData = useContext(FolderContex
我在使用预签名网址和 AFNetworking 3.0 从 S3 获取图像时遇到问题。我可以使用 NSMutableURLRequest 和 NSURLSession 获取图像,但是当我使用 AFHT
我正在使用 Oracle ojdbc 12 和 Java 8 处理 Oracle UCP 管理器的问题。当 UCP 池启动失败时,我希望关闭它创建的连接。 当池初始化期间遇到 ORA-02391:超过
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 9 年前。 Improve
引用这个plunker: https://plnkr.co/edit/GWsbdDWVvBYNMqyxzlLY?p=preview 我在 styles.css 文件和 src/app.ts 文件中指定
为什么我的条形这么细?我尝试将宽度设置为 1,它们变得非常厚。我不知道还能尝试什么。默认厚度为 0.8,这是应该的样子吗? import matplotlib.pyplot as plt import
当我编写时,查询按预期执行: SELECT id, day2.count - day1.count AS diff FROM day1 NATURAL JOIN day2; 但我真正想要的是右连接。当
我有以下时间数据: 0 08/01/16 13:07:46,335437 1 18/02/16 08:40:40,565575 2 14/01/16 22:2
一些背景知识 -我的 NodeJS 服务器在端口 3001 上运行,我的 React 应用程序在端口 3000 上运行。我在 React 应用程序 package.json 中设置了一个代理来代理对端
我面临着一个愚蠢的问题。我试图在我的 Angular 应用程序中延迟加载我的图像,我已经尝试过这个2: 但是他们都设置了 src attr 而不是 data-src,我在这里遗漏了什么吗?保留 d
我是一名优秀的程序员,十分优秀!