angular-ui / ui-leaflet

AngularJS directive to embed an interact with maps managed by Leaflet library
http://angular-ui.github.io/ui-leaflet
Other
315 stars 137 forks source link

Unable to use controllerAs syntax on controls attribute #18

Open nmccready opened 8 years ago

nmccready commented 8 years ago

From @Raptormstr on April 2, 2014 14:1

jQuery considers the attribute "controls" as a reserved word and will rename any string to simple "controls". Look at the jQuery.js source code lines 623 & 6888 for 2.1.0 and 665 & 7960 for 1.11.0. I do not believe jqLite has this same issue.

For example: Before $compile: After $compile:

NOTE: I removed the other attributes and classes for brevity.

The only workaround if jQuery is required is to use the variable name "controls" and assign it to the $scope.

Copied from original issue: tombatossals/angular-leaflet-directive#348

nmccready commented 8 years ago

From @tombatossals on April 2, 2014 17:3

You're right, good point.

What would you suggest to solve this? Rename the attribute, like "lfControls", for example?

nmccready commented 8 years ago

From @Raptormstr on April 3, 2014 7:34

I believe renaming the attribute is the only option. Since Angular will execute the jQuery code long before this directive, there is no way to intervene. Also, "controls" is an HTML5 attribute for audio and video so it should not be used at all.

As for your namespace suggestion, that would work but it should be applied to all the attributes for consistency.

Stephen On Apr 2, 2014 1:03 PM, "David Rubert" notifications@github.com wrote:

You're right, good point.

What would you suggest to solve this? Rename the attribute, like "lfControls", for example?

Reply to this email directly or view it on GitHubhttps://github.com/tombatossals/angular-leaflet-directive/issues/348#issuecomment-39356110 .

nmccready commented 8 years ago

From @jsthivierge on March 5, 2015 16:30

Got a similar problem. I used grunt-contrib-htmlmin task to minimize my html and since controls is a HTML5 attribute and my scope variable is named controls (<leaflet controls="controls"></leaflet>), it got renamed to <leaflet controls></leaflet>.

The htmlmin task option collapseBooleanAttributes was set to true, therefore controls="controls" was collapsed to controls since it's an html5 attribute...

Any idea if the attributes will be renamed soon to prevent this type of conflict?