Angularjs Error: [$ compile: tpload] Failed to load the template

I am trying to create a simple routing program in angularjs. I have an index.html main page with ng-view div and javascript for routing. Also two simple html pages view2.html and view3.html are placed in a subfolder partials1. I am getting below the error. Please, help.

Error: access denied. Error: [$ compile: tpload] Failed to load the template: partials1 / view3.html http://errors.angularjs.org/1.3.15/ $ compile / tpload? p0 = partials1% 2Fview3.html

  • index.html

    <div data-ng-view></div> <script src="angular.js"></script> <script src="angular-route.js"></script> <script type="text/javascript"> var demoApp = angular.module('demoApp', [ 'ngRoute' ]); demoApp.controller('SimpleController', function($scope) { $scope.customers = [ { name : 'Jon Smith1', city : 'Charlotte' }, { name : 'John Doe', city : 'New York' }, { name : 'Jane Doe', city : 'Jacksonville' } ]; }); demoApp.config([ '$routeProvider', function($routeProvider) { $routeProvider.when('/view1', { templateUrl : 'partials1/view3.html', controller : 'SimpleController' }).when('/view2', { templateUrl : 'partials1/view2.html', controller : 'SimpleController' }).otherwise({ redirectTo : '/view1' }); } ]); </script> 

  • view2.html

     <div class="container">33333333333333</div> 
  • view3.html

     <div class="container">33333333333333</div> 
+5
source share
4 answers

Error: Access is denied reports that the template is unavailable. Try opening the template in your browser. Something like this: http: //my_project/partials1/view3.html . To see the full URL used by your application, use the dubug console (XHR tab).

+4
source
 Error: [$compile:tpload] Failed to load template: xyz.html (HTTP status: 404 Not Found) 

may be caused by the installation below in web.config

  <system.webServer> <handlers> <remove name="BlockViewHandler"/> <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" /> 

This blocks any direct request to the file in the Views directory. Angular xhr request to this file is blocked by this.

Comment on this and see if everything works. Use this with caution, as it provides access to your files.

You can also check this url for more answers: Error: $ compile: tpload could not load the template Status Http: 404

+1
source

In my case, the problem is that I added Default headers such as Accept = 'application / json'. So my routes suddenly stopped working, because these headers were not only applied to my calls in http.post, they were also applied to my routing ...? Weird

0
source

I had the same error, in my case the web server was written using node js, and the uri to get the views that were in the specified path with $ stateProvider was not created, because for each viewed / selected template to display HTTP request type Xhr GET.

Since uri did not exist, I got 404 code, and this caused the browser to enter the callback that killed it. Make sure your server returns the requested view. (Translation with google translation)

0
source

All Articles