抱歉,如果我在这里遗漏了一些愚蠢的东西,但我真的尝试了各种组合来使这段代码工作,但没有运气。
我正在学习但停留在这段代码directive
中AngularjS
-Recipes with AngularJS
https://github.com/fdietz/recipes-with-angular-js-examples/tree/master/chapter3/recipe4
我相信它应该在Hello World文本之前打印Heading 。但它不会来。让我知道我的代码中缺少什么- p
代码作为一个整体 -
<!doctype html>
<html lang="en" ng-app="myApp">
<head>
<meta charset="utf-8" />
<title>Directive Example</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.10/angular.min.js"></script>
<script>
var myApp = angular.module("myApp", []);
myApp.directive("myWidget", function(){
return {
restrict: "E",
transclude: true,
template: "<div ng-transclude><h3>Heading</h3></div>"
};
});
</script>
</head>
<body>
<my-widget>
<p>Hello World!!</p>
</my-widget>
</body>
</html>