我正在使用我在互联网上找到的Select类,问题是如果我在Select dinnamically中创建选项,使用angluar ng-repeat,该选项将无法点击,但如果我手动创建,也是使用动态值,可以单击它。
这是代码:
MainFile:
...
<div id="SiteList" ng-controller="SiteController as siteCtrl" ng-if="masterCtrl.isUserLogged()" ng-include="'Select2/index.html'" ng-init="siteCtrl.getSites()" >
...
这是Select2 / index.html ...
<body>
<div class="drop">
<div class="option active placeholder" data-value="placeholder">
Seleziona un sito
</div>
<div class="option" ng-repeat="sito in siteCtrl.siti" data-value="{{sito.name}}">{{sito.name}}</div>
</div>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src="Select2/js/index.js"></script>
</body>
...
然后是Select2 / js / index.js
$(document).ready(function() {
$(".drop .option").click(function() {
var val = $(this).attr("data-value"),
$drop = $(".drop"),
prevActive = $(".drop .option.active").attr("data-value"),
options = $(".drop .option").length;
$drop.find(".option.active").addClass("mini-hack");
$drop.toggleClass("visible");
$drop.removeClass("withBG");
$(this).css("top");
$drop.toggleClass("opacity");
$(".mini-hack").removeClass("mini-hack");
if ($drop.hasClass("visible")) {
setTimeout(function() {
$drop.addClass("withBG");
}, 400 + options*100);
}
triggerAnimation();
if (val !== "placeholder" || prevActive === "placeholder") {
$(".drop .option").removeClass("active");
$(this).addClass("active");
};
});
function triggerAnimation() {
var finalWidth = $(".drop").hasClass("visible") ? 22 : 20;
$(".drop").css("width", "24em");
setTimeout(function() {
$(".drop").css("width", finalWidth + "em");
}, 400);
}
});
任何人都知道如何解决这个问题?
答案 0 :(得分:0)