Giter Club home page Giter Club logo

leaflet-popup-angular's Introduction

leaflet-popup-angular

Use AngularJS in your Leaflet popups. Extends the built-in L.popup.

Supports Leaflet v1.0.0

For Leaflet 0.7.7 support see leaflet-popup-angular v0.1.2

See working examples.

Usage

Basic

	var popup = L.popup.angular({
		template: `
			<div>
				<h1>{{popup.$content.title}} - <small>{{popup.$content.name}}</small></h1>
				<div>
					My custom popup with controller. {{popup.hello}}
				</div>
			</div>
		`,
		controllerAs: 'popup',
		controller: ['$content', function($content){
			this.hello = 'Hello';
			$content.on(function(content){
				console.log('This executes on setContent', content);
			});
		}]
	}).setLatLng(latlng).setContent({
	    	'name': 'foo',
	    	'title': 'bar'
	    })
	    .openOn(map);

No Controller

	var popup = L.popup.angular({
		template: `
			<div>
				<h1>{{$content.title}} - <small>{{$content.name}}</small></h1>
				<div>
					My popup without a controller.
				</div>
			</div>
		`,
	}).setLatLng(latlng).setContent({
	    	'name': 'foo',
	    	'title': 'bar'
	    })
	    .openOn(map);

Note

For clarity, these examples are using template literals to represent multiline strings. Template literals are part of ES6 and are not supported by some browsers (notably IE). See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

This is a new package. We will be introducing support for angular's templateUrl soon and the examples will be reimplemented using this feature.

For production use at this time, either:

  • Use a bundler like webpack to insert the html into your template-- template: require('template.html')
  • Use template literals and a tool like babel to compile down to ES5
  • Use oldschool JavaScript strings in place of template literals

Dependency Injection

In addition to the rest of your Angular application's services, L.popup.angular also provides several of its own services through dependency injection to the controller.

  • $content Content object. Register callbacks for setContent() with $content.on()
  • $map Leaflet map object
  • $options The options params from L.popup.angular.

leaflet-popup-angular's People

Contributors

grantharris avatar rey-awesense avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

leaflet-popup-angular's Issues

Timeline for templateUrl?

Any idea on when the templateUrl feature will be added? I'd like to try this plugin out on a project.

Angular popup

does this plugin works with angular not angular JS?

Add bower support

Hi,

This is a great extension of the Leaflet popup class and has saved me a lot of trouble. Would love to see it ready for Bower, and with a little more documentation.

Would be great if the template could directly reference data available in the controller it is being created within instead of having the isolated scope it seems to have (requiring a controller or passing in data via setContent).

Thanks,

Matt

$injector undefined

Getting
Uncaught TypeError: Cannot read property 'get' of undefined
on
var $rootScope = $injector.get('$rootScope'),
$compile = $injector.get('$compile'),
$controller = $injector.get('$controller');
when ng-app is set on a child of <html> (such as <body>).

angular.element('[ng-app]').injector() should fix the issue.

Angular 2

Is this available for angular 2 ? or can it be used with angular 2?

Thanks

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.