久久久久久久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 標記彈出窗口中使用 Angular 指令

      How to use Angular directives ng-click and ng-class inside Leaflet marker popup(如何在 Leaflet 標記彈出窗口中使用 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 標記彈出窗口中使用 Angular 指令 ng-click 和 ng-class的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

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

                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>');
                

                但是,當我檢查元素時,我得到了這個:

                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 應該向該函數發送特定對象和對象數組,但是當我單擊圖標時沒有任何反應.在我的研究中,我發現彈出窗口會阻止事件傳播(更多信息但我不是確定如何覆蓋它或修復它以使其與 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 評估一個字符串,我將變量固定為:

                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 會正確輸出:

                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>
                

                但是,當我單擊該圖標時,什么也沒有發生,并且看起來函數沒有被調用.有人知道為什么會發生這種情況嗎?

                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?

                推薦答案

                您的問題來自于您手動創建了一些 DOM,而這些 DOM 不是由 AngularJS 編譯的.

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

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

                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 字符串,并首先將其轉換為 DOM.因為 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 服務將此 DOM 編譯為鏈接函數.

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

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

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

                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)
                

                請注意,我給出的范圍是 $scope 的子范圍.如果不這樣做,您將在所有彈出窗口之間共享相同的范圍,這不是一個好主意.創建新范圍是在 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()
                

                從中可以得到實際的 DOM 節點

                From that you can get the actual DOM node

                linkFunction(scope)[0]
                

                并將其傳遞給 Leaflet

                And pass it to Leaflet

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

                你就完成了!

                有關詳細信息,請參閱 compiler 文檔.

                For more info, please refer to the compiler doc.

                關于范圍的更正問題

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

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

                相關文檔推薦

                Check if a polygon point is inside another in leaflet(檢查一個多邊形點是否在傳單中的另一個內部)
                Changing leaflet markercluster icon color, inheriting the rest of the default CSS properties(更改傳單標記群集圖標顏色,繼承其余默認 CSS 屬性)
                Trigger click on leaflet marker(觸發點擊傳單標記)
                How can I change the default loading tile color in LeafletJS?(如何更改 LeafletJS 中的默認加載磁貼顏色?)
                Add external geojson to leaflet layer(將外部geojson添加到傳單層)
                Adding Leaflet layer control to sidebar(將 Leaflet 圖層控件添加到側邊欄)
                • <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激情在线| 中文一级片 | 久久精品97 | 伊人网一区 | 国产精品乱码一区二三区小蝌蚪 | 久久69精品久久久久久久电影好 | 一区二区三区免费看 | 99re在线视频 | 亚洲欧美在线一区 | 日韩一区二区福利视频 | 性色视频| 欧美一级片在线 | 久久这里只有精品首页 | 久久伊人在| 久久成人亚洲 | 日韩在线一区二区 | 最近最新中文字幕 | 成人在线免费观看 | 国产精品毛片久久久久久 | 日韩欧美一级片 | 国产精品亚洲视频 | 欧美6一10sex性hd | 亚洲天堂网站 | 国产精品国产精品国产专区不蜜 | 狠狠爱视频 | 成人午夜高清 | 一区二区三区在线 | 国产精品一区二区久久 | 欧美激情综合五月色丁香小说 | 在线免费观看视频黄 | h漫在线观看| 亚洲一区二区视频 | 日韩欧美在线观看 | 天天操伊人 | 欧美精品久久久 | 91麻豆精品国产91久久久久久 |