0

I want to set part of an url of an html <object> tag with an angular variable, but I get a lot of error messages in the console, because the presented string looks like

http://...../%7B%7Bvarname%7B%7B/....

I had the same problem with the <img> tag, but there I could use the ng-src directive. I guess I need to write my own directive, but what are the things I need to look out for?

<object type="application/x-shockwave-flash" height="378" width="620" id="live_embed_player_flash" data="http://...?chan={{varname}}" bgcolor="#000000">
    ...
    <param name="flashvars" value="hostname=...&chan={{varname}}" />
</object>

1 Answer 1

1

Try this:

<object ... data="{{address}}">

Controller:

$scope.varname = "something";
$scope.address = "http://...?chan=" + $scope.varname;

Fiddle

Sign up to request clarification or add additional context in comments.

8 Comments

Thanks, but should this work? Because for me it does exactly what I expected, nothings gets "interpreted". The final html output includes {{'http://...?chan='+varname}} and of course the error message stays the same.
@KenavR varname should be a scope model. Take a look at my update.
@KenavR Try storing the entire address in a scope variable and then using that inside the HTML.
It always was a $scope variable and I can correctly output it with {{varname}}, but as an attribute value it doesn't work. It does get correctly "interpreted" eventually, but the browser is faster fetching the markup, than angular is with replacing the {{variables}}. (docs.angularjs.org/api/ng.directive:ngSrc) I guess I need to dig more into ngSrc and go on with my search.
Did you try with my latest update? By having the entire address in a scope variable instead of concatenating in the HTML?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.