1

I have this states: first one in partial view and second one is html page and they are in folder View/Account.First one is working but secondone is not.It say 404 page could not be found. How can i configure state for .html page.Any suggestion?

.state('account.payoutconfirmation', {
    url: '/ticketprint',
    templateUrl:
        function (stateParams) {
            return mainTemplateService.getTemplateUrl(stateParams, '/account/payoutconfirmation');
        }
}).state('account.state', {
    url: '/printticket',
    templateUrl:
        function (stateParams) {
            return mainTemplateService.getTemplateUrl(stateParams, "/account/state.html")
        }
Radim Köhler
  • 122,561
  • 47
  • 239
  • 335
None
  • 8,817
  • 26
  • 96
  • 171

1 Answers1

0

I would say, there could be some typo. Anyhow, in case we are using some mainTemplateService to load the url, we should not use templateUrl, but templateProvider.

There is a working plunker

This could be the service:

  .factory('mainTemplateService', ['$templateRequest', function($templateRequest) {
    return {
      getTemplateUrl: function(stateParams, urlPart) {
        var url = "temp" + urlPart; 
        return $templateRequest(url); 
      }
    }
  }])

And these are states:

.state('account.payoutconfirmation', {
  url: '/ticketprint',
  templateProvider: ['$stateParams', 'mainTemplateService',
    function(stateParams, mainTemplateService) {
      return mainTemplateService.getTemplateUrl(stateParams, '/account/payoutconfirmation');
  }],
})
.state('account.state', {
  url: '/printticket',
  templateProvider: ['$stateParams', 'mainTemplateService',
    function(stateParams, mainTemplateService) {
      return mainTemplateService.getTemplateUrl(stateParams, "/account/state.html")
  }],
})

Check it here

Also, check these:

Community
  • 1
  • 1
Radim Köhler
  • 122,561
  • 47
  • 239
  • 335