Jassica
Jassica

Reputation: 143

templateUrl not working with AngularUI-Router

Can you guys explain how the flow works when url get hit? and why angular template url not working?

The question is when the url clicked on the browser, it might go to the cache for URL saved from $stateprovider.state and then might go to find the file as I defined like below, and then where does it go ? if they need to they might go to asp.net core controller to fetch data. Am I understanding right?

The problem I am having is .. TemplateUrl is not pointing to the folder in the file . I tested it with another file in a different folder but it works fine other than this file.

$stateProvider.state("users.index", {
    url: "/",
    templateUrl: "/users/index",
    //template:'<p>test</p>',
    controller: "userController",
    resolve: {
        viewModel: ["userService", function (userService) {
            return userService.getAllUsers();
        }]
    }
});

Upvotes: 0

Views: 38

Answers (1)

GregL
GregL

Reputation: 38103

After Angular UI Router determines the correct state to activate from the URL, it gets the templateUrl value for that state.

First, it checks the $templateCache service to see if it has an entry for /users/index. If it does, it uses it and is done.

If not, it uses the $templateRequest service to request that URL from the server. Since I don't know how your server is configured, I don't know what will be returned by that URL.

Hopefully that helps you get a bit further in figuring this out.

Upvotes: 1

Related Questions