久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    • <bdo id='jx7dz'></bdo><ul id='jx7dz'></ul>
    <i id='jx7dz'><tr id='jx7dz'><dt id='jx7dz'><q id='jx7dz'><span id='jx7dz'><b id='jx7dz'><form id='jx7dz'><ins id='jx7dz'></ins><ul id='jx7dz'></ul><sub id='jx7dz'></sub></form><legend id='jx7dz'></legend><bdo id='jx7dz'><pre id='jx7dz'><center id='jx7dz'></center></pre></bdo></b><th id='jx7dz'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='jx7dz'><tfoot id='jx7dz'></tfoot><dl id='jx7dz'><fieldset id='jx7dz'></fieldset></dl></div>
  1. <small id='jx7dz'></small><noframes id='jx7dz'>

  2. <legend id='jx7dz'><style id='jx7dz'><dir id='jx7dz'><q id='jx7dz'></q></dir></style></legend>
    1. <tfoot id='jx7dz'></tfoot>

      如何在 Leaflet 標(biāo)記彈出窗口中使用 Angular 指令

      How to use Angular directives ng-click and ng-class inside Leaflet marker popup(如何在 Leaflet 標(biāo)記彈出窗口中使用 Angular 指令 ng-click 和 ng-class)

      <small id='WbEf8'></small><noframes id='WbEf8'>

      <i id='WbEf8'><tr id='WbEf8'><dt id='WbEf8'><q id='WbEf8'><span id='WbEf8'><b id='WbEf8'><form id='WbEf8'><ins id='WbEf8'></ins><ul id='WbEf8'></ul><sub id='WbEf8'></sub></form><legend id='WbEf8'></legend><bdo id='WbEf8'><pre id='WbEf8'><center id='WbEf8'></center></pre></bdo></b><th id='WbEf8'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='WbEf8'><tfoot id='WbEf8'></tfoot><dl id='WbEf8'><fieldset id='WbEf8'></fieldset></dl></div>
        <tbody id='WbEf8'></tbody>
      • <tfoot id='WbEf8'></tfoot>

            • <legend id='WbEf8'><style id='WbEf8'><dir id='WbEf8'><q id='WbEf8'></q></dir></style></legend>
              • <bdo id='WbEf8'></bdo><ul id='WbEf8'></ul>

                本文介紹了如何在 Leaflet 標(biāo)記彈出窗口中使用 Angular 指令 ng-click 和 ng-class的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                問(wèn)題描述

                我正在使用 Angular.JS 和 Leaflet.JS 作為我所在位置的地圖,該地圖具有綁定了彈出窗口的地圖標(biāo)記.我需要使用一個(gè)帶有兩個(gè)不同圖標(biāo)(一個(gè)在下面的代碼中顯示)的跨度,您可以單擊它們來(lái)調(diào)用不同的函數(shù),并在滿足某些條件時(shí)使用 ng-class 來(lái)更改類(lèi).這是我的代碼:

                I'm using Angular.JS and Leaflet.JS for a map in my location that has map markers with popups binded to them. I need to use a span with two different icons (one shown in code below) that you can click to call different functions and with ng-class to change the class if certain conditions are met. This is my code:

                var marker = L.marker([51.5, -0.09], {icon: blueIcon}).bindPopup('<br><span ng-class="thumbsUpClass(' + hotelsSelectedDates[i]['hotels'][s] + ')" ng-click="addChoice(' + hotelsSelectedDates[i]['hotels'][s] + ',' + hotels + ')"><span class="popup-container"><span class="icon-stack thumbs-up-stack"><i class="icon-sign-blank icon-stack-base"></i><i class="icon-thumbs-up"></i></span></span></span>');
                

                但是,當(dāng)我檢查元素時(shí),我得到了這個(gè):

                However when I inspect the element I get this:

                <span ng-class="thumbsUpClass([object Object])" ng-click="addChoice([object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object])"><span class="popup-container"><span class="icon-stack thumbs-up-stack"><i class="icon-sign-blank icon-stack-base"></i><i class="icon-thumbs-up"></i></span></span></span>
                

                ng-click 應(yīng)該向該函數(shù)發(fā)送特定對(duì)象和對(duì)象數(shù)組,但是當(dāng)我單擊圖標(biāo)時(shí)沒(méi)有任何反應(yīng).在我的研究中,我發(fā)現(xiàn)彈出窗口會(huì)阻止事件傳播(更多信息但我不是確定如何覆蓋它或修復(fù)它以使其與 Angular 一起使用.有人知道如何完成此操作嗎?

                The ng-click should send that function both the specific object and the array of objects but when I click the icon nothing happens. In my research I found that the popup prevents event propagation (more info but I'm not sure how to override it or a fix to get it to work with angular. Would anyone have an idea of how to accomplish this?

                更新:

                由于 ng-click/class 評(píng)估一個(gè)字符串,我將變量固定為:

                Since ng-click/class evaluate a string I fixed the variables to be like this:

                $scope.item = hotelsSelectedDates[i]['hotels'][s]
                $scope.set = hotels
                var marker = L.marker([51.5, -0.09], {icon: blueIcon}).bindPopup('<br><span ng-class="thumbsUpClass(item)" ng-click="addChoice(item,set)"><span class="popup-container"><span class="icon-stack thumbs-up-stack"><i class="icon-sign-blank icon-stack-base"></i><i class="icon-thumbs-up"></i></span></span></span>');
                

                然后 html 會(huì)正確輸出:

                The html then comes out correctly:

                <span ng-class="thumbsUpClass(item)" ng-click="addChoice(item,set)"><span class="popup-container"><span class="icon-stack thumbs-up-stack"><i class="icon-sign-blank icon-stack-base"></i><i class="icon-thumbs-up"></i></span></span></span>
                

                但是,當(dāng)我單擊該圖標(biāo)時(shí),什么也沒(méi)有發(fā)生,并且看起來(lái)函數(shù)沒(méi)有被調(diào)用.有人知道為什么會(huì)發(fā)生這種情況嗎?

                However when I click the icon nothing happens and it doesn't look like the functions are being called. Anyone have any clue why this would happen?

                推薦答案

                您的問(wèn)題來(lái)自于您手動(dòng)創(chuàng)建了一些 DOM,而這些 DOM 不是由 AngularJS 編譯的.

                Your issue comes from the fact that you are manually creating some DOM, which was not compiled by AngularJS.

                在這些情況下,您必須手動(dòng)編譯和鏈接元素.

                In those cases, you have to manually compile and link the element.

                代碼如下所示:

                var html = '<br><span ng-class="thumbsUpClass(item)" ' +
                    'ng-click="addChoice(item,set)"><span class="popup-container"><span ' +
                    'class="icon-stack thumbs-up-stack"><i class="icon-sign-blank ' +
                    'icon-stack-base"></i><i class="icon-thumbs-up"></i></span></span></span>',
                    linkFunction = $compile(angular.element(html)),
                    newScope = $scope.$new();
                
                newScope.item = hotelsSelectedDates[i]['hotels'][s]
                newScope.set = hotels
                var marker = L.marker([51.5, -0.09], {icon: blueIcon}).bindPopup(linkFunction(newScope)[0]);
                

                在這里,我獲取您的 HTML 字符串,并首先將其轉(zhuǎn)換為 DOM.因?yàn)?AngularJS 吃的是 DOM,而不是字符串.

                Here I take your HTML string, and I start by transforming it into DOM. Because AngularJS eats DOM, not strings.

                angular.element(html)
                

                然后,我使用 $compile 服務(wù)將此 DOM 編譯為鏈接函數(shù).

                Then, I compile this DOM into a link function, using the $compile service.

                linkFunction = $compile(angular.element(html));
                

                執(zhí)行時(shí),此函數(shù)將返回一個(gè)完全由 Angular 控制的 jQuery DOM 樹(shù),并在您作為參數(shù)提供給它的范圍內(nèi)運(yùn)行.這就是我在這里所做的

                When executed, this function will return a jQuery DOM tree fully controlled by Angular, running in the scope you give to it as argument. This is what I do here

                linkFunction(newScope)
                

                請(qǐng)注意,我給出的范圍是 $scope 的子范圍.如果不這樣做,您將在所有彈出窗口之間共享相同的范圍,這不是一個(gè)好主意.創(chuàng)建新范圍是在 var 聲明中完成的

                Please note that the scope I give is a child scope of $scope. Without doing this, you would share the same scope between all popups, and this would not be a good idea. Creating the new scope was done in the var declaration

                newScope = $scope.$new()
                

                從中可以得到實(shí)際的 DOM 節(jié)點(diǎn)

                From that you can get the actual DOM node

                linkFunction(scope)[0]
                

                并將其傳遞給 Leaflet

                And pass it to Leaflet

                .bindPopup(linkFunction(newScope)[0]);
                

                你就完成了!

                有關(guān)詳細(xì)信息,請(qǐng)參閱 compiler 文檔.

                For more info, please refer to the compiler doc.

                關(guān)于范圍的更正問(wèn)題

                這篇關(guān)于如何在 Leaflet 標(biāo)記彈出窗口中使用 Angular 指令 ng-click 和 ng-class的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                相關(guān)文檔推薦

                Check if a polygon point is inside another in leaflet(檢查一個(gè)多邊形點(diǎn)是否在傳單中的另一個(gè)內(nèi)部)
                Changing leaflet markercluster icon color, inheriting the rest of the default CSS properties(更改傳單標(biāo)記群集圖標(biāo)顏色,繼承其余默認(rèn) CSS 屬性)
                Trigger click on leaflet marker(觸發(fā)點(diǎn)擊傳單標(biāo)記)
                How can I change the default loading tile color in LeafletJS?(如何更改 LeafletJS 中的默認(rèn)加載磁貼顏色?)
                Add external geojson to leaflet layer(將外部geojson添加到傳單層)
                Adding Leaflet layer control to sidebar(將 Leaflet 圖層控件添加到側(cè)邊欄)
                • <small id='qTiZP'></small><noframes id='qTiZP'>

                      <tbody id='qTiZP'></tbody>
                    • <bdo id='qTiZP'></bdo><ul id='qTiZP'></ul>

                      <tfoot id='qTiZP'></tfoot>

                        <legend id='qTiZP'><style id='qTiZP'><dir id='qTiZP'><q id='qTiZP'></q></dir></style></legend>

                        1. <i id='qTiZP'><tr id='qTiZP'><dt id='qTiZP'><q id='qTiZP'><span id='qTiZP'><b id='qTiZP'><form id='qTiZP'><ins id='qTiZP'></ins><ul id='qTiZP'></ul><sub id='qTiZP'></sub></form><legend id='qTiZP'></legend><bdo id='qTiZP'><pre id='qTiZP'><center id='qTiZP'></center></pre></bdo></b><th id='qTiZP'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='qTiZP'><tfoot id='qTiZP'></tfoot><dl id='qTiZP'><fieldset id='qTiZP'></fieldset></dl></div>
                          主站蜘蛛池模板: av在线一区二区三区 | 久久久九九九九 | 欧美日韩18 | 久久爱一区 | 日本三级电影在线免费观看 | 精品国产一区二区三区免费 | 日韩一区二区三区在线视频 | 毛片网在线观看 | 日韩一级免费看 | 国产精品亚洲二区 | 国产精品九九九 | 午夜成人免费视频 | 黄a免费看 | 欧美αv | 国产成人精品一区二区三区 | 国产精品网页 | 欧美日韩高清在线一区 | 在线一级片 | 久草高清视频 | 国产美女久久久 | 黄色在线免费观看视频 | 青久草视频 | 在线毛片网 | 欧美日韩高清 | 免费色网址| 欧美精品在线免费观看 | 美女久久久久 | 久久精品亚洲精品国产欧美 | 精品无码久久久久久国产 | 天天色综| 日韩精品成人 | 精品国产31久久久久久 | 仙人掌旅馆在线观看 | 国产98色在线 | 日韩 | 日韩欧美在线视频 | 日韩av在线一区二区 | 欧美日韩黄色一级片 | 激情视频中文字幕 | 国产精品久久久久久久久图文区 | av在线播放网址 | 少妇午夜一级艳片欧美精品 |