2016-06-27 83 views
1

試圖學習如何使用這個插件,但我似乎無法完成任何工作。有人能指引我朝着正確的方向嗎?這是一個拉拉維爾項目,但這應該沒有太大的區別。pickadate.js根本不工作

這裏是我的html:

<p><input id="date" class="form-control" ng-model="currentWimDate" placeholder="Date..." type="text"></p> 

和我index.blade.php:

<html lang="en" ng-app="wim"> 
<head> 
    <meta charset="utf-8"> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 

    <title>WIM(afy)</title> 

    <link href="bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"> 
    <link href="css/wimmain.css" rel="stylesheet"> 
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> 
    <link rel="stylesheet" href="bower_components/pickadate/lib/themes/default.css" id="theme_base"> 
    <link rel="stylesheet" href="bower_components/pickadate/lib/themes/default.date.css" id="theme_date"> 
    <link rel="stylesheet" href="bower_components/pickadate/lib/themes/default.time.css" id="theme_time"> 

    <script src="bower_components/angular/angular.min.js"></script> 
    <script src="bower_components/ng-file-upload-shim/ng-file-upload-shim.min.js"></script> 
    <script src="bower_components/ng-file-upload/ng-file-upload.min.js"></script> 
    <script src="bower_components/lodash/lodash.js"></script> 
    <script src="bower_components/angular-route/angular-route.min.js"></script> 
    <script src="bower_components/angular-local-storage/dist/angular-local-storage.min.js"></script> 
    <script src="bower_components/restangular/dist/restangular.min.js"></script> 

    <script src = "js/app.js"></script> 
    <script src = "js/services.js"></script> 
    <script src = "js/controllers.js"></script> 
    <script src = "js/checkPass.js"></script> 
    <script src = "js/signupValidation.js"></script> 
    <script src = "js/dropdown.js"></script> 
    <script src = "js/profileActions.js"></script> 

    <style> 

     li { 
      padding-bottom: 8px; 
     } 

    </style> 
</head> 

<body style="background-color: #ef5350;">  
    <div ng-view></div> 


    <script src="bower_components/jquery/dist/jquery.min.js"></script> 
    <script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script> 
    <script src="bower_components/pickadate/lib/picker.js"></script> 
    <script src="bower_components/pickadate/lib/picker.date.js"></script> 
    <script src="bower_components/pickadate/lib/picker.time.js"></script> 

    <script type="text/javascript"> 
    // PICKADATE FORMATTING 
    $('#date').pickadate({ 
     format: 'mmmm d, yyyy',  // Friendly format displayed to user 
     formatSubmit: 'mm/dd/yyyy', // Actual format used by application 
     hiddenName: true   // Allows two different formats 
    }); 
    </script> 
</body> 

什麼我錯在這裏做什麼?

回答

0

我認爲您的jQuery代碼在Angular完成將#date放入您的HTML之前正在運行。因此,jQuery找不到你正在尋找的元素,所以沒有任何反應。您可以輸出$('#date')的結果來測試。嘗試在Angular完成渲染後運行pickadate代碼。這裏有一個question可能會幫助你。