The Videogular Angular video player likes to have videos referenced in an object like this:
{
preload: "auto",
sources: [
{
src: $sce.trustAsResourceUrl("http://static.videogular.com/assets/videos/videogular.mp4"),
type: "video/mp4"
}
],
theme: "bower_components/videogular-themes-default/videogular.css"
}
$sce.trustAsResourceUrl
runs the URL through ng-sanitize
to prevent malicious code.
In my controller I make this object after uploading the video to Firebase Storage, which returns a snapshot
object:
var videoObject = {
preload: "auto",
sources: [
{
src: "$sce.trustAsResourceUrl(" + $scope.snapshot.downloadURL + ")",
type: "video/" + $scope.mediaFormat
},
],
theme: {
url: "http://www.videogular.com/styles/themes/default/latest/videogular.css"
}
};
The result is:
{
preload: "auto",
sources: [
{
src: "$sce.trustAsResourceUrl(http://static.videogular.com/assets/videos/videogular.mp4)",
type: "video/mp4"
}
],
theme: "bower_components/videogular-themes-default/videogular.css"
}
That doesn't work because the src
key's value is a string, when I want a $sce.trustAsResourceUrl
not to be a string.
If I make the object this way:
var videoObject = {
preload: "auto",
sources: [
{src: $sce.trustAsResourceUrl +'("' + $scope.snapshot.downloadURL + '")', type: "video/" + $scope.mediaFormat}
],
theme: {
url: "http://www.videogular.com/styles/themes/default/latest/videogular.css"
}
};
then I get:
{
preload: "auto",
sources: [
{
src: "function (b){return g(a,b)}(\"http://static.videogular.com/assets/videos/videogular.mp4)",
type: "video/mp4"
}
],
theme: "bower_components/videogular-themes-default/videogular.css"
}
According to Mozilla, "A JavaScript object is a mapping between keys and values. Keys are strings (or Symbols) and values can be anything." If values can be anything, how do I make a value that is partly a string and partly not a string? What is "partly a string and partly not a string" called? A literal?