Here is the callstack of the wrong request..
<https://lh3.googleusercontent.com/-k5jpzGj7Z9U/VgVtEPefslI/AAAAAAAAEsg/CtEpyBk2U2E/s1600/Captura%2Bde%2Bpantalla%2B2015-09-25%2Ba%2Blas%2B10.47.52.png>
El viernes, 25 de septiembre de 2015, 10:30:30 (UTC-5), William Vega
escribió:
>
> ng-src is a great directive, it allows you to hide de src request for an
> image until angular has fully loaded. I am having a bad time trying to
> figure out how can I reproduce this directive's behavior in my own
> directive in order to do the same but for loading CSS.
>
> Here is my code so far:
>
> .directive('xStyle',
>
> function()
> {
>
> return {
>
> restrict: 'E',
> replace: true,
> scope: { xUrl : '=' },
> template:'<style>' +
> ' @import url("{{xUrl}}")' +
> '</style>',
>
> };
> }
> );
>
> very simple (it seems), the problem is that it doesn't work as expected,
> since there is a double request being made to the server from the app
> (ionic bundle, but angular 1.28 after all), the first request looks
> something like this:
>
> http://serverAddress/{{xUrl}}
>
> (well actually url encoded, I put it like this to increase the readability
> to better illustrate the issue. Then, after the values are loaded (binding
> the template to the directive parameters), a second request is issued to
> the server, this time with the right url and therefore getting the proper
> css and all works well.
>
> What I want is get rid of the first GET request to the server that the
> browser does, it seems to me that by compiling somehow this code in an
> earlier phase could probably render the compiled code with the actual
> params and avoid those milliseconds in which the uncompiled version is
> rendered and the wrong request is generated. The problem is that after
> reading the angular js documentation for directive I know there is a
> compile and link phase but I have no clue on how to approach this.
>
> Any ideas?
>
> Thanks for your kind help.
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.