angular-daterangepicker不使用angularJs

时间:2017-01-23 08:00:26

标签: jquery angularjs bootstrap-daterangepicker angular-daterangepicker

我一直在尝试在我的一个应用程序中使用angular-daterangepicker。我正在关注此链接:

https://github.com/fragaria/angular-daterangepicker

  1. 安装了模块。
  2. 在控制器中写入依赖。
  3. 使用脚本标记在.html / .ejs文件中添加依赖项。
  4. echo "!cassandra/" >>.git/info/sparse-checkout
    

    错误:

      

    1)TypeError:el.daterangepicker不是函数

         

    2)TypeError:无法设置未定义的属性'date'

    如何摆脱这个错误?

1 个答案:

答案 0 :(得分:0)

这是一个有效的例子 - 你需要下载并包含" angular-daterangepicker.min.js"此文件来自https://github.com/fragaria/angular-daterangepicker

    

<head>
    <meta charset="utf-8">
    <title>Daterange picker example</title>

    <!-- bower:css -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-daterangepicker/2.1.13/daterangepicker.min.css" />
    <!-- endbower -->

</head>

<body>
    <!-- bower:js -->
    <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.20/angular.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.20/angular-messages.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-daterangepicker/2.1.13/daterangepicker.min.js"></script>
    <!-- endbower -->

    <script src="angular-daterangepicker-master/js/angular-daterangepicker.min.js"></script>

<div class="container">
    <h1>Daterange picker example</h1>

    <div class="row">
        <div class="col-md-6" ng-controller="TestCtrl">
            <form name="dateForm" class="form-horizontal">
                <div class="form-group">
                    <label for="daterange1" class="control-label">Simple picker</label>
                    <input date-range-picker id="daterange1" name="daterange1" class="form-control date-picker" type="text"
                           ng-model="date" required/>
                </div>
      </form>

            <div class="row">
                <h4>Model:</h4>
                <div class="col-md-12 well">
                    <label>Date range:</label><br>
                    {{date | json}}<br>
                    <label>Single date:</label><br>
                    {{singleDate | json}}<br>
                </div>
            </div>
        </div>
    </div>
</div>
</body>


<script>
exampleApp = angular.module('example', ['ngMessages', 'daterangepicker']);
exampleApp.controller('TestCtrl', function($scope) {
    $scope.date = {
        startDate: null,
        endDate: null
    };


});

angular.bootstrap(document, ['example']);</script>

</html>