我有我想用 JsBin 演示的工作代码,但我无法让 AngularJS 指令templateUrl工作(它确实与模板值一起工作)。 http://jsbin.com/guvok/试图引用http://jsbin.com/razit/但失败了。
为了完整和后代,这里的代码:
你好.html
<!DOCTYPE html>
<html ng-app="hello">
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js"></script>
</head>
<body>
<div hello></div>
</body>
</html>
你好.css
.hello__content {
background: #fff;
}
你好.js
var meter = angular.module('hello', [])
.directive( 'hello', function() {
return {
restrict: 'A',
replace: true,
//template: '<p class="hello__content">hello</p>',
templateUrl: 'http://jsbin.com/razit/',
};
});
模板.html
<p>hello, world</p>