I have some constants defined in my app like so:
angular.module('MyModule')
.constant('myConstant', {
'userId': '0000',
'playerId': '1111'
});
I'd like to use them in a script URL like so:
<script ng-src="http://domain.com/{{myConstant.userId}}/{{myConstant.playerId}}"></script>
I'm aware that $sce disallows this type of interpolation, so I've tried using a scope function to return sanitized tokens (using Controller As syntax):
{{ctrlAlias.getUserId()}}
ctrlAlias.getUserId = function ($sce) {
return $sce.trustAsResourceUrl(ctrlAlias.ctrlVar.userId);
};
This is apparently wrong, though. It returns the same error:
Strict Contextual Escaping disallows interpolations that concatenate multiple expressions when a trusted value is required.
Is this sort of tokenization feasible in a script source, and what's the right way to handle it? Should I be employing a service to build the entire source URL instead? I'd rather not use Grunt's string replacement in this case.
Thanks a bunch.