I am writing an AngularJS website and I need a dynamic templateUrl.
If I hardcode my url template, my routing works.
when('/levelthree', {
templateUrl: 'views/levelthree/1.001_WhitePaper.htm',
controller: 'LevelThreeController'
}).
When I try this, it does not.
when('/levelthree', {
templateUrl: function () {
return 'views/levelthree/' + retrieveStorageItem('LevelThreeDocumentSelected');
},
controller: 'LevelThreeController'
}).
How can I have a dynamic templateUrl that works while passing in the document url when clicked on?
// HREF
<a id=\"a0\" style=\"color: rgb(0, 0, 0);\" href=\"#levelthree\" data-url=\"1.001_WhitePaper.htm\">White Paper <i
class=\"fa fa-play\" style=\"color: rgb(0, 128, 0);\"></i></a>
// URL of the HREF, when clicked.
http://localhost:65155/testwebsite/Index.html#levelthree
// Code that gets the document I need.
$(document).on("click", ".openLevelThree", function (e) {
var documentSelected = $(this).children('a').attr('data-url');
setStorageItem("LevelThreeDocumentSelected", documentSelected);
});
I've looked at this but I do not see where I would have access to the $scope to see if it would work for me.