Skip to content

"rz-slider-tpl-url" Not working? #354

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

Closed
hanying33 opened this issue Jun 22, 2016 · 27 comments
Closed

"rz-slider-tpl-url" Not working? #354

hanying33 opened this issue Jun 22, 2016 · 27 comments
Labels

Comments

@hanying33
Copy link

I tried to use "rz-slider-tpl-url" attribute to customize my slider, but can't get it work. I looked at the source js file, looks like it's always pointing to the provided template. If this feature is working properly, could anyone please provide a demo example?

I am using the js/css file from dist directory.

Thank you!

@ValentinH
Copy link
Member

It should work and there is already a demo for it: http://angular-slider.github.io/angularjs-slider/ - "Slider with custom template to use HTML formatting for ticks"

@hanying33
Copy link
Author

I followed the demo, but it didn't work. Is there anything else I need to keep an eye on?

Maybe by understanding the src code can help me with using this attribute. Could you please provide some explaination of the src code piece?

@ValentinH
Copy link
Member

There you go: https://github.com/angular-slider/angularjs-slider/blob/master/src/rzslider.js#L2049

If you still cannot fix your issue, please provide a JSFiddle showing what you are trying to do, and I'll help you. ;)

@hanying33
Copy link
Author

hanying33 commented Jun 24, 2016

Thanks Valentin. What's the difference between src/rzslider.js and
dist/rzslider.js? I see this extra code in dist/rzslider.js:

`
module.run(['$templateCache', function($templateCache) {
'use strict';

$templateCache.put('rzSliderTpl.html',
"

<span class="rz-bar rz-selection" ng-style=barStyle> <span class="rz-pointer rz-pointer-min" ng-style=minPointerStyle> <span class="rz-pointer rz-pointer-max" ng-style=maxPointerStyle> <span class="rz-bubble rz-limit rz-floor"> <span class="rz-bubble rz-limit rz-ceil">
    <li ng-repeat="t in ticks track by $index" class=rz-tick ng-class="{'rz-selected': t.selected}" ng-style=t.style ng-attr-uib-tooltip="{{ t.tooltip }}" ng-attr-tooltip-placement={{t.tooltipPlacement}} ng-attr-tooltip-append-to-body="{{ t.tooltip ? true : undefined}}"><span ng-if="t.value != null" class=rz-tick-value ng-attr-uib-tooltip="{{ t.valueTooltip }}" ng-attr-tooltip-placement={{t.valueTooltipPlacement}}>{{ t.value }} <span ng-if="t.legend != null" class=rz-tick-legend>{{ t.legend }}
"
);
`

@ValentinH
Copy link
Member

The dist file just contains the inline default template.

@hanying33
Copy link
Author

I put the custom template file on the same level as the html file that uses th rzslider directive (for example, index.html), it's working.

Now, I have another question:

How do I pass the variables being defined in my own controller (for example, index.js) to the custom template file?

@ValentinH
Copy link
Member

I don't think it's possible because there are 2 different scopes.

@hanying33
Copy link
Author

Well, it could be a nice feature for the next release ;)

@ValentinH
Copy link
Member

How would you implement such a feature? I don't see how this is possible because this is due to the isolation of scopes in Angular...

@hanying33
Copy link
Author

One way I can think of is to add a customizable option for user, for example, an option with a key named "myOption", user can pass in an object that contains any thing the user wants as a value, then user can use that object in custom templte.

@ValentinH
Copy link
Member

OK, I see now. I can add this feature as a customScope option.

@ValentinH
Copy link
Member

Do you have an example of use case for this feature?

@hanying33
Copy link
Author

Great. I don't have live code for you at the moment. I'll explain here:

Under a partial directory, I have four files:

  • mySliderTpl.html
  • myPage.html
  • myController.js
  • myPage.css

I wish to have "customScope" variable being defined in myController.js, for example:
customScope = {'updating_time': '14:23:07', 'other': 'some value here'}
The value of 'updating_time' will be updated every second by the js code, which will be reflected in mySliderTpl.html, so that I can show the running time in my browser.

Please let me know if you need more details. Thanks!

@ValentinH
Copy link
Member

But why does it have to be displayed in the slider template? Cant you just display it outside of it in its own template/directive?

@hanying33
Copy link
Author

hanying33 commented Jul 6, 2016

That's by design. Need to have it on template. A customscope would be very
beneficial.

@ValentinH
Copy link
Member

The time value is displayed on the slider?

@hanying33
Copy link
Author

hanying33 commented Jul 6, 2016

Yep. It's not just the time value, could be something else too. Just need
to imtegrate on the slider template.

@ValentinH
Copy link
Member

I'm sorry to insist but I have seen so many users that needed a feature for the slider while they could have done it themselves, outside of the library. I don't want the library to implement all the custom features of every users so I want to make sure of that.

Could you please provide a mock-up of what you want to achieve?

@hanying33
Copy link
Author

hanying33 commented Jul 6, 2016

I understand that. But I don't think I can implement this myself, I will
share the mockup with you tmr. Thanks!

@ValentinH
Copy link
Member

👍

@hanying33
Copy link
Author

hanying33 commented Jul 6, 2016

Here is the mockup, it simulates a playing video slider. I need to display the tooltip beside the slider as it moves, and update the tooltip value every second.

screenshot from 2016-07-06 11-14-40

@ValentinH
Copy link
Member

OK I see, but don't you think that the tooltip should be handled in the chart part?

@hanying33
Copy link
Author

Well. I wish. But that's by design, so I don't have a choice, I have to
implement it as the mockup. I really appreciate your help, this feature
would be a bonus.

@ValentinH
Copy link
Member

I mean, the tooltip should be handled by the chart, this is not the slider concern

@hanying33
Copy link
Author

The expected result is to have the tooltip move with the green slider (When
video is playing, the green slider will auto move to the right one step
every second, and also the tooltip). The only way I can think of is to
implement it in the custom template.

On Wed, Jul 6, 2016 at 1:29 PM, Valentin Hervieu notifications@github.com
wrote:

I mean, the tooltip should be handled by the chart, this is not the slider
concern


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#354 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AGFBxszj9pDB5C_4a3kHybJAJs6hNGXoks5qTBA3gaJpZM4I8TO4
.

@ValentinH
Copy link
Member

Added this option in 5.2.0:
customTemplateScope - Object (default to null): The properties defined in this object will be exposed in the slider template under custom.X.

@hanying33
Copy link
Author

Great! Thank you very much! Can't wait to use this feature ;)

On Wed, Jul 6, 2016 at 11:17 PM, Valentin Hervieu notifications@github.com
wrote:

Added this option in 5.2.0:
customTemplateScope - Object (default to null): The properties
defined in this object will be exposed in the slider template under
custom.X.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#354 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AGFBxvubMrxl_OPZIT-THhqfI2hP68MSks5qTJoJgaJpZM4I8TO4
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants