1

If I should use

templateUrl: 'Content/Custom/Login.html'

it will work only when user is in Home/Index controller. And it should not if user will be at another controller something like Home/About.

http://localhost:7602/Home/Content/Custom/Login.html Failed to load resource:

Because template is situated in

http://localhost:7602/Content/Custom/Login.html

How to fix this? What is the right way of template declaration?

$mdDialog.show({
        controller: DialogController,
        templateUrl: 'Content/Custom/Login.html',
        parent: angular.element(document.body),
        targetEvent: ev,
        clickOutsideToClose: true,
        fullscreen: useFullScreen
    })
    .then(function (answer) {
        $scope.status = 'You said the information was "' + answer + '".';
    }, function () {
        $scope.status = 'You cancelled the dialog.';
    });
1
  • Have you defined <base href="/">? Commented May 15, 2016 at 20:27

2 Answers 2

2

Try using Absolute Path to your partials

for instance If your app is in App Directory than use:

templateUrl: '/App/Content/Custom/Login.html
Sign up to request clarification or add additional context in comments.

Comments

0

Declare somewhere in your _Layout.cshtml

<script>
        window.contentUrl = @Html.Raw(HttpUtility.JavaScriptStringEncode(Url.Content("~/Content/"), true));
</script>

Then use it in your templateUrl as

templateUrl: contentUrl + "/Custom/Login.html'

1 Comment

This is a neat solution, but relies on ASP.NET Razor, which wasn't mentioned in the question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.