i'm using ng-boilerplate , have add possibility use different templates in production, based on user configuration.
.config(function config( $stateprovider ) { $stateprovider.state( 'demo', { url: '/demo', views: { "main": { controller: 'democtrl', templateurl: 'demo/demo.tpl.html' } } }); }) my current idea make templateurl dynamic
templateurl: 'demo/demo'+userservice.gettemplate()+'.tpl.html' and having multiple template files, like:
- demo.tpl.html (default)
- demo.b.tpl.html (version b)
- demo.c.tpl.html (version c)
while userservice function provide template version use, e.g. ".b"
do agree? there maybe better/easier approach problem?
angularjs standard $routeprovider can accept function templateurl. can't inject services function.
ui-router has templateprovider parameter can inject want , should return remote template case:
$stateprovider.state('demo', { templateprovider: function ($http, $templatecache, $stateparams, userservice) { var url = 'demo/demo' + userservice.gettemplate() + '.tpl.html'; return $http.get(url, { cache: $templatecache }).then(function (response) { return response.data; }); } })
Comments
Post a Comment