简体   繁体   English

错误:[$ compile:tpload]无法在Angular中加载模板

[英]Error: [$compile:tpload] Failed to load template in Angular

Example : 范例:

registry.html registry.html

<label>Name:</label>

app.js app.js

 define(['angular', 'services','text',
'text!ang/templates/registry.html'], function(angular, services,textmod,template) {
    ........
        angular.module('myApp.directives', ['myApp.services'])
        .directive('superd', function() {
                      return {

                               templateUrl:template,
                                   ..........
                                }
                })

Eror : 错误:

GET app_ang/%3Clabel%3EName:%3C/label%3E 403 (Forbidden) angular.js?bust=1417672731204137.41101580671966:10023 GET app_ang /%3Clabel%3EName:%3C / label%3E 403(禁止)angular.js?bust = 1417672731204137.41101580671966:10023

Error: [$compile:tpload] Failed to load template: <label>Name:</label> 错误:[$ compile:tpload]无法加载模板: <label>Name:</label>

Note : 'text' is https://github.com/requirejs/text 注意:'text'是https://github.com/requirejs/text

I don't think you need to depend on 'text' directly. 我认为您不需要直接依赖'text'

define([
  'angular', 
  'services', 
  'text!ang/templates/registry.html'
], function(angular, services, template) {
  //...
  angular.module('myApp.directives', ['myApp.services'])
         .directive('superd', function() {
           return {
             templateUrl: template,
             //...
           };
         });

And in your require config: 并在您的require config中:

require.config({
  //...
  paths: {
    // path example if you are using bower
    'angular': '/bower_components/angular/angular',
    'text': '/bower_components/requirejs-text/text'
  },

  shim: {
    'angular': {
      exports: 'angular'
    }
  }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Angular JS错误:$ compile:tpload:无法加载模板: - Angular JS Error: $compile:tpload: Failed to load template: angularjs错误:[$ compile:tpload]无法加载模板 - angularjs Error: [$compile:tpload] Failed to load template 错误:$compile:tpload 无法加载模板 Http 状态:404 - Error: $compile:tpload failed to load template Http status : 404 AngularJS - 错误:[$compile:tpload] 无法加载模板(Spring Boot) - AngularJS - Error: [$compile:tpload] Failed to load template (Spring Boot) Angular ngRoute无法加载模板:错误[$ compile:tpload] - Angular ngRoute can't load template: Error [$compile:tpload] AngularJS: [$compile:tpload] 无法加载模板 - AngularJS: [$compile:tpload] Failed to load template 错误:[$ compile:tpload]无法加载模板:uib / template / pagination / pagination.html(HTTP状态:404未找到) - Error: [$compile:tpload] Failed to load template: uib/template/pagination/pagination.html (HTTP status: 404 NOT FOUND) $ compile:tpload未能加载模板(HTTP状态:404)仅在一个子URL中发生 - $compile:tpload Failed to load template (HTTP status: 404) happens in one sub url only Angular / grunt无法加载模板 - Angular / grunt failed to load template 无法在角度$ mdDailog中加载模板 - Failed to load template in angular $mdDailog
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM