Integrate a angular datepicker with my application

0

I have a problem that I do not know very well how to integrate an angular angle datepicker for my application I have been trying to do it but I do not know where I have the error I show you my controller app files etc ..

controller.js:

myApp.controller('empController', function($route,$scope,$http,$routeParams){
    $scope.getCitas = function(){
        $http.get('../api/select.php').then(function(response){
            $scope.citas = response.data;
        });
    };
    $scope.addCita = function(info){
        $http.post('../api/insert.php', info).then(function(response){
            window.location.href = 'http://localhost/webCitas/crud_APM3/client/home.php#/';
        });
    };
    $scope.showCita = function(){
        var idCita = $routeParams.idCita;
        $http.post('../api/selectone.php',{'idCita':idCita}).then(function(response){
            var emp  = response.data;
            $scope.cita = emp[0];
        });
    };
    $scope.updateCita = function(info){
        $http.post('../api/update.php', info).then(function(response){
            window.location.href = 'http://localhost/webCitas/crud_APM3/client/home.php#/';
        });
    };
    $scope.deleteCita = function(idCita){
        var idCita = idCita;
        $http.post('../api/delete.php',{'idCita':idCita}).then(function(response){
            $route.reload();
        });
    };
    $scope.getHoras = function (fechaInicio) {
         // En la llamada pasas fecha de inicio como argumento para el php.
         $http.get('../api/horas.php?='+fechaInicio).then(function (response) {
             $scope.citas = response.data;
         });
     };
    $scope.getCitasPublico = function(){
        $http.get('../api/selectPublico.php').then(function(response){
            $scope.citas = response.data;
        });
    };
});
angular
  .module('Demo', ['moment-picker', 'ngMaterial'])
  .controller('DemoController', ['$scope', function () {
    var ctrl = this;

    // noop.
  }]);

create.html:

<div class="form-group">
                <label for="fechaInicio">Fecha de la cita:</label>
                <div class="input-group date fecha">
                    <div ng-cloak style="padding:20px;"
                ng-controller="DemoController as ctrl"
                layout="column"
                layout-padding>

            <md-content class="md-no-momentum">
              <md-input-container class="md-icon-float md-block">
                <label>Select a date...</label>
                <md-icon md-font-library="material-icons">today</md-icon>
                <input moment-picker="ctrl.stringDate"
                       locale="en"
                       format="YYYY-MM-DD"
                       ng-model="ctrl.momentDate"
                       ng-model-options="{ updateOn: 'blur' }">
              </md-input-container>
            </md-content>
</div>
</div>
</div>

I just put the part of the "datepicker".

    
asked by Peter 21.12.2017 в 16:52
source

1 answer

1

I use angular-datepicker without any problem:

1. install via npm

npm install angularjs-datepicker --save

2. add it in your index.html:

<!DOCTYPE HTML>
<html>
<head>
    <link href="src/css/angular-datepicker.css" rel="stylesheet" type="text/css" />
</head>

<body ng-app="app">
<script src="src/js/angular-datepicker.js"></script>
</body>
</html>

3. And now add it in the component you want:

<datepicker>
<input ng-model="date" type="text"/>
</datepicker>
    
answered by 22.12.2017 в 13:15