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

Pass variable to template #19

Closed
sylouuu opened this issue May 26, 2015 · 4 comments
Closed

Pass variable to template #19

sylouuu opened this issue May 26, 2015 · 4 comments

Comments

@sylouuu
Copy link

sylouuu commented May 26, 2015

Hey, thank you for that.

For some requests, I wanna show my loader, sometimes, it must be hidden.

So I have a boolean global variable in $rootScope that I have to pass trough the title attribute. Which is pretty dirty.

Btw, when my loader is shown, I can see the title as a tooltip (HTML standard) with "true" as a string...

Example:

<!-- Loader template -->
<script type="text/ng-template" id="spinner.tpl.html">
    <div ng-if="title === 'true'">
        <div class="spinner-overlay">
            <div class="spinner-container">
                <div class="loader6"></div>
            </div>
        </div>
    </div>
</script>

<!-- Show loader -->
<div ng-http-loader ttl="0" template="spinner.tpl.html" title="{{ page.loader }}"></div>

{{ page.loader }} is a boolean. Beside, this boolean is casted into a string (see my ng-if).

I suggest to add another attribute to do something like this.

<!-- Loader template -->
<script type="text/ng-template" id="spinner.tpl.html">
    <div ng-if="data === true">
        <div class="spinner-overlay">
            <div class="spinner-container">
                <div class="loader6"></div>
            </div>
        </div>
    </div>
</script>

<!-- Show loader -->
<div ng-http-loader ttl="0" template="spinner.tpl.html" data="page.loader"></div>

I hope this is enough clear.

Bests

@zazoomauro
Copy link
Contributor

Hi @sylouuu
I have a different approach. You can enable or disable the loader creating the ng-http-loader directive with a simple ng-if
make sense?

@sylouuu
Copy link
Author

sylouuu commented Jul 13, 2015

Hey,

I tried. It doesn't work as expected.

Regards

@zazoomauro
Copy link
Contributor

Why? The loader will not been shown. Is exactly what you want

@sylouuu
Copy link
Author

sylouuu commented Jul 21, 2015

You have right. I didn't think about that:

<script type="text/ng-template" id="spinner.tpl.html">
    <div>
        <div class="spinner-overlay">
            <div class="spinner-container">
                <div class="loader6"></div>
            </div>
        </div>
    </div>
</script>

<!-- Show loader -->
<div ng-http-loader ttl="0" template="spinner.tpl.html" ng-show="page.loader"></div>

Thanks

@sylouuu sylouuu closed this as completed Jul 21, 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