Since it is an asp.net mvc app, you should take advantage of helper methods like Url.Action
or Url.Content
or Url.RouteUrl
. In your razor view you may use either of these methods to generate the path to your app base root/or a specific root and pass that to your angular controller/angular services/directives.
So in your razor view/layout file, you may do this.
@section Scripts
{
<script src="~/Scripts/YourAngularControllerFileForThisPage.js"></script>
<script>
var yourApp = yourApp || {};
yourApp.Settings = yourApp.Settings || {};
yourApp.Settings.BaseUrl= "@Url.Content("~")";
angular.module("app").value("appSettings", yourApp);
</script>
}
You can access this appSettings
object in your angular directive and use the Settings.BaseUrl
property to build the full url to your directive template.
(function () {
angular.module("app")
.directive("myDirective", function (appSettings) {
return {
restrict: 'E',
templateUrl: appSettings.Settings.BaseUrl
+'Scripts/MyDirectives/searchableMultiselect.html',
controller: function ($scope) {
// some code
}
}
});
})();
This will load the searchableMultiselect.html
file from ~/Scripts/MyDirectives
location.