示例:
registry.html
<label>Name:</label>
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:
获取app_ang /%3Clabel%3EName:%3C / label%3E 403(禁止) angular.js?bust = 1417672731204137.41101580671966:10023
错误:[$ compile:tpload]无法加载模板:<label>Name:</label>
注意:'text'为https://github.com/requirejs/text
答案 0 :(得分:1)
我认为你不需要直接依赖'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,
//...
};
});
在您的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'
}
}
});