I am having trouble getting a custom directive (one that does autocomplete google places) to work properly inside a ui bootstrap modal window. It works perfectly outside the window. If i put it inside the modal-body div, no suggestions show up. If I put it in between the body and footer divs, it looks funky.
在ui引导模式窗口中,我很难让自定义指令(自动完成谷歌位置的指令)正常工作。它在窗外很好地工作。如果我将它放在modal-body div中,就不会出现任何建议。如果我把它放在身体和脚底之间,它看起来很时髦。
I believe this issue is relevant but cannot figure out how exactly:
我认为这个问题是相关的,但我不知道具体是如何:
My index.html:
我的index . html。
<body>
<div ng-controller="ModalDemoCtrl">
<button class="btn btn-default" ng-click="open('lg')">Large modal</button>
<div ng-show="selected">Selection from a modal: {{ selected }}</div>
</div>
<-- this form works fine -->
<form id="form2" role="form">
<div class="form-group move-down">
<input type="text" id="Autocomplete2" class="form-control" ng-autocomplete="result1" details="details1" options="options1" />
</div>
</form>
</body>
JS:
JS:
'use strict';
angular.module('myApp.directives', []).
.directive('ngAutocomplete', function($parse) {
return {
scope: {
details: '=',
ngAutocomplete: '=',
options: '='
},
link: function(scope, element, attrs, model) {
//options for autocomplete
var opts;
//convert options provided to opts
var initOpts = function() {
opts = {};
if (scope.options) {
if (scope.options.types) {
opts.types = [];
opts.types.push(scope.options.types)
}
if (scope.options.bounds) {
opts.bounds = scope.options.bounds
}
if (scope.options.country) {
opts.componentRestrictions = {
country: scope.options.country
}
}
}
};
initOpts();
//create new autocomplete
//reinitializes on every change of the options provided
var newAutocomplete = function() {
scope.gPlace = new google.maps.places.Autocomplete(element[0], opts);
google.maps.event.addListener(scope.gPlace, 'place_changed', function() {
scope.$apply(function() {
scope.details = scope.gPlace.getPlace();
scope.ngAutocomplete = element.val();
});
})
};
newAutocomplete();
//watch options provided to directive
scope.watchOptions = function () {
return scope.options
};
scope.$watch(scope.watchOptions, function () {
initOpts();
newAutocomplete();
element[0].value = '';
scope.ngAutocomplete = element.val();
}, true);
}
};
});
Here is the relevant plunker
这是相关的活塞
ANY help or guidance would be greatly appreciated. I have spent 3 days on this issue. Fixing this would help me also with another directive I want to use. Thanks!
如有任何帮助或指导,将不胜感激。在这个问题上我已经花了三天的时间。修正这个问题也可以帮助我处理另一个我想要使用的指令。谢谢!
1 个解决方案
#1
3
well victorsoto had the correct solution.
维克托索托有正确的解决办法。
i added this to my style.css and it now works fine!
这是我的风格。css现在运行得很好!
.pac-container {
z-index: 99999999;
}
#1
3
well victorsoto had the correct solution.
维克托索托有正确的解决办法。
i added this to my style.css and it now works fine!
这是我的风格。css现在运行得很好!
.pac-container {
z-index: 99999999;
}