Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong API id if id contains an angular expression #25

Closed
warpdesign opened this issue Dec 8, 2014 · 5 comments
Closed

Wrong API id if id contains an angular expression #25

warpdesign opened this issue Dec 8, 2014 · 5 comments

Comments

@warpdesign
Copy link
Contributor

When using an Angular expression into the panzoom element's id, the raw (not parsed) expression will be used as elementId:

scope.elementId = element.attr('id');

Ending up with a wrong index in API when calling PanZoomService.registerAPI:

So if you have something like

<panzoom ... id="{{expression}}"></panzoom>

scope.elementId === '{{expression}}'

I think parsing the angular expression would fix the problem.

@warpdesign
Copy link
Contributor Author

I answer my own question: replacing this:

scope.elementId = element.attr('id');

with

scope.elementId = attrs['id']:

fixes the problem since attrs will contain the interpolated attribute.

@mvindahl
Copy link
Owner

mvindahl commented Dec 8, 2014

Hi warpdesign,

Having both the problem and a one-line solution served on a silver platter makes for an excellent day in Developerville :-)

Thanks for pointing out the issue. I'll integrate the fix ASAP.

Cheers,
/Martin

@warpdesign
Copy link
Contributor Author

Great! :)

Unfortunately I found other problems. Similar fix is needed in panzoomwidget directive, compile function:

panzoomId = tElement.attr('panzoom-id');

Again, this uses the non interpolated id. Problem is we do not have access to the interpolated value into the compile function.

I ended up using the pre/post functions to get the panzoomId. And I had to move the code from the controller into this function since controller method would be called before the pre/post functions, so before the pannzoomId is set.

In the end this is quite a lot of changes. If you want I could make a pull request with the changes.

@mvindahl
Copy link
Owner

mvindahl commented Dec 8, 2014

Hi,

Thanks for your offer. A pull request would be much appreciated :)

Just out of curiousity .. do you use a large number of simultaneous panzoom directives on your page?

Cheers,
/Martin

@warpdesign
Copy link
Contributor Author

Not a large number. I'd say we use 1-5 max panzoom directives.

I'll make a pull request later this week then :)

@mvindahl mvindahl closed this as completed Jan 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants