使用角度js从数据选择器获取数据 [英] Get data from data picker using angular js
本文介绍了使用角度js从数据选择器获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我下载了包含html,css和java脚本的日期选择器代码。它运作良好。但我想使用角度js从日期选择器打印或获取所选日期。我写了一个代码,但它打印 undefined 。我不知道我哪里错了。这是我的代码。
I download the date picker code which consist html, css and java script. Its working well. But i want to print or get the selected date from the date picker using angular js. I wrote a code that, but it prints undefined. i dn't know where i was wrong. this is my code.
<!DOCTYPE html>
<html ng-app>
<head>
<link rel="stylesheet" type="text/css" href="assets/css/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="assets/css/todc-bootstrap.css" />
<link rel="stylesheet" type="text/css" href="assets/css/todc-datepicker.css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" src="assets/js/bootstrap-datepicker.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<script src="assets/js/angular.js"></script>
<style type="text/css">
html,body { margin: 20px; }
</style>
</head>
<body>
<form class="form-horizontal" ng-controller="MyController">
<div class="control-group">
<label class="control-label" for="dt1">Select Date</label>
<div class="controls">
<div class="input-append">
<input class="span2" id="dt1" type="text" ng-model="selectedDate" />
<button class="btn" type="button" id="cal1"></button>
</div>
<input class="btn" type="button" value="submit" ng-click="add()">
</div>
<h6 class="control-label"> selected date : </h6>
</div>
</form>
</body>
<script type="text/javascript">
$(function() {
$('#cal1').datepicker({
autoclose: true,
todayHighlight: true,
targetInput: $("#dt1")
});
});
function MyController($scope) {
$scope.add = function() {
alert($scope.selectedDate);
}
}
</script>
</html>
推荐答案
( function (){
(' #cal1')。datepicker({
autoclose: true ,
todayHighlight: true ,
targetInput:
('#cal1').datepicker({ autoclose: true, todayHighlight: true, targetInput:
( #dt1)
});
});
function MyController(
("#dt1") }); }); function MyController(
这篇关于使用角度js从数据选择器获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文