2

After building my application with Grunt, ui.router is still trying to access templateUrl urls. As these have been concatenated by ngTemplates this does not work and I just get a number of 404 errors.

I'm new to this and don't really understand what I'm doing

$stateProvider
    .state("home", {
      url: "/",
      views: {
        'master': {templateUrl: '/views/main.html'},
        "view-left@home": {
          templateUrl: '/views/list.html'
        },
        "view-right@home": {
          templateUrl: '/views/page.html'
        }
      }
    })

This works when I use grunt serve, but breaks when I build the application

[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (main.html, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (page.html, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (list.html, line 0)

Let me know if you need more information, I'm not really sure what is relevant.

Edit:

grunt.registerTask('build', [
'clean:dist',
'wiredep',
'useminPrepare',
'concurrent:dist',
'autoprefixer',
'ngtemplates',
'concat',
'ngAnnotate',
'copy:dist',
'cdnify',
'cssmin',
'uglify',
'filerev',
'usemin',
'htmlmin'
]);

This is my build task.

2
  • what is does your build task look like? Commented Sep 21, 2015 at 2:54
  • @rabble Could you please post your grunt configuration of 'ngtemplates'. Commented Oct 25, 2017 at 16:47

1 Answer 1

5

I seem to have fixed it. The issue was that in my state, the templateUrl was '/views/main.html', but in the templateCache it was 'views/main.html' (without the first slash). Removing the first slash from the templateUrls fixed the issue.

Sign up to request clarification or add additional context in comments.

1 Comment

omg i was trying to fix this since two day. Many thanks for the hint.

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.