GithubHelp home page GithubHelp logo

Comments (3)

nmccready avatar nmccready commented on August 15, 2024

From @tombatossals on May 25, 2014 14:56

Hi, you have to compile the message as it contains dynamic HTML, so it must be re-parsed by angular.

Take a look at threads on stackoverflow.com talking about this. There's must be an easy way for sure:

http://stackoverflow.com/questions/19845950/angularjs-how-to-dynamically-add-html-and-bind-to-controller
http://stackoverflow.com/questions/18157305/angularjs-compiling-dynamic-html-strings-from-database

Hope it helps.

from ui-leaflet.

nmccready avatar nmccready commented on August 15, 2024

From @wootwoot1234 on May 25, 2014 23:25

I'll check out the links and thanks for answering both of my last two posts!

Am I approaching this problem incorrectly? All I want to do is to make the marker's label clickable. Seems like something that other people would want too, right?

from ui-leaflet.

nmccready avatar nmccready commented on August 15, 2024

From @nicolaspayot on September 17, 2014 9:52

Hi,

In case someone's looking for a solution to this issue:

// Here we are manually creating DOM that is not compiled by AngularJS
var title = '<span><a ng-click="hello()">' + Hello, World! + '</a> - <b>item1</b><br />item2</span>';

// Compile title DOM into a link function
var linkFn = $compile(angular.element(title));
// Return a jQuery DOM tree fully controlled by AngularJS so that ng directives will work
var popup = linkFn(scope);

var mark = L.marker(new L.LatLng(item.lat, item.lng));
// We can only display a DOM node (bug with leaflet?) so this is why we use <span>...</span> as a parent node
mark.bindPopup(popup[0]);
...
scope.hello = function() {
    alert('Hello, World!');
};

The ng-click directive's working now!

from ui-leaflet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.