我对这个函数做什么,要计算与控制功能的时间差"dayResult()"
,但如果我在写代码,棱角分明的功能停止working.can有人告诉如何打通dayresult()
函数结果
.html文件
<html>
<head>
<meta charset="utf-8" />
<title>AngularJS Plunker</title>
<script>document.write('<base href="' + document.location + '" />');</script>
<link rel="stylesheet" href="style.css" />
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" media="screen" href="http://tarruda.github.com/bootstrap-datetimepicker/assets/css/bootstrap-datetimepicker.min.css">
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
<script type="text/javascript" src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/js/bootstrap.min.js">
</script>
<script type="text/javascript" src="http://tarruda.github.com/bootstrap-datetimepicker/assets/js/bootstrap-datetimepicker.min.js">
</script>
<script data-require="angular.js@1.0.x" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js" data-semver="1.0.8"></script>
<script src="app.js"></script>
</head>
<body>
<div ng-app="plunker" class="container container-fluid" ng-controller="MainCtrl">
<!-- <form class="form-horizontal" novalidate name="form" ng-submit="submit()">
<div class="well">-->
<div id="date" class="input-append" datetimez ng-model="var1">
<input data-format="MM-dd-yyyy" type="text" id="input1" name="input1"></input>
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
</span>
</div>
<div id="date" class="input-append" datetimez ng-model="var2">
<input data-format="MM-dd-yyyy" type="text" id="input1" name="input1" ></input>
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
</span>
</div>
<!-- </div>
</form>-->
var1={{var1}}
<br>
var2={{var2}}
<br>
<!-- here is day result function -->
difference= {{dayResult()}} days
</div>
<script>
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.dayResult = function()
{
}
});
app.directive('datetimez', function() {
return {
restrict: 'A',
require : 'ngModel',
link: function(scope, element, attrs, ngModelCtrl) {
element.datetimepicker({
dateFormat:'dd-MM-yyyy',
language: 'en',
pickTime: true,
startDate: '01-11-2013', // set a minimum date
endDate: '01-11-2030' // set a maximum date
}).on('changeDate', function(e) {
ngModelCtrl.$setViewValue(e.date);
scope.$apply();
});
}
};
});
</script>
</body>
</html>
答案 0 :(得分:0)
添加返回值并不能解决问题吗?
$scope.dayResult = function()
{
return "test";
}