简体   繁体   English

jQuery调用在我的AngularJS页面中不起作用

[英]JQuery calls doesn't work in my AngularJS page

JQuery selectors in this page of my project doesn't work, they calls autocomplete method and datepicker in the same way as other pages where works properly. 我项目的此页面中的jQuery选择器不起作用,它们以与其他页面正常工作的相同方式调用自动完成方法和日期选择器。

This is my code, i reviewed it 420 times and again. 这是我的代码,我反复审查了420次。

If i try to fill the input field should call get method in dati.js but it seems like the $ selector doesn't work, because is not working neither for .datepicker 如果我尝试填写输入字段,则应在dati.js中调用get方法,但似乎$选择器不起作用,因为这对.datepicker都不起作用

Controller 控制者

angular.module('AceApp').controller('praticaCtrl', function($scope, $window, $http, $timeout, $rootScope, $state, $stateParams, $location, $auth, $uibModal, dati, $compile, $filter) {
    $( ".datapicker" ).datepicker({
        changeMonth: true,
        changeYear: true,
        yearRange: "1900:2050",
        dateFormat: 'dd-mm-yy'
});
$(".dataPickerModal").datepicker({
    changeMonth: true,
    changeYear: true,
    yearRange: "1900:2050",
    dateFormat: 'dd-mm-yy'
}).css({"z-index":10000});
////////////
$("#luogoNascita").autocomplete({
    source: function (request, resolve) {
        console.log("vvv");
        dati.getCitta(request.term)
            .success(function (data) {
               resolve(data);
            })
            .error(function () {
            });
        }
    });

$("#luogoNascita").on("autocompleteselect", function(event, ui) {
    $timeout(function() {
        $scope.cliente.comune_nascita.sigla = ui.item.sigla;
        $scope.cliente.comune_nascita.codice_catastale = ui.item.codiceCatastale;
    });
}); ETC...

HTML 的HTML

<div class="col-md-3 col-sm-3 col-xs-7">
    <label for="luogoNascita">Luogo di Nascita</label>
    <input ng-model = "cliente.comune_nascita.nome" autocomplete = "on" 
           type="text" class="form-control" name="luogoNascita"
           id="luogoNascita" placeholder="Ricerca Città" style="width:100%" />
</div>

APP.JS APP.JS

.state('pratica', {
    url: '/pratica/:id',
    title: 'Dati anagrafici',
    icon: 'fa fa-dollar',
    view: false,
    sottomenu: false,
    templateUrl: 'views/pages/pratiche/pratica.html',
    permissions: 'quinto-stipendio_pratica',
    controller: 'praticaCtrl',
    resolve: {
        lazyLoad: ['$ocLazyLoad', function($ocLazyLoad) {
            return $ocLazyLoad.load([
                {
                    serie: true,
                    name: 'dataTables',
                    files: ['../components/datatables/media/js/jquery.dataTables.js', '../components/_mod/datatables/jquery.dataTables.bootstrap.js', '../components/angular-datatables/dist/angular-datatables.js']
                },
                {
                    name: 'AceApp',
                    files: ['js/controllers/pages/pratiche/pratica.js']
                },
                {
                    name: 'stepF',
                    files: ['js/controllers/pages/dropzone/uploader.js']
                }
            ]);
        }]
    },
    permissions: 'leggi-cessione_quinto'
})

I've only copy-pasted this code from other pages where it works, and there are no differences. 我只是将代码复制到了其他可以工作的页面上,没有任何区别。

Well .. you cannot just use $() in AngularJS. 好吧..您不能只在AngularJS中使用$()。

There are solutions to combine jquery and angularjs 有结合jquery和angularjs的解决方案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM