【发布时间】:2016-01-20 01:30:21
【问题描述】:
学习 AngularJS,我似乎看不出我的自定义指令有什么问题。使用修改后的 w3 学校代码来展示我的问题的更简单示例。
当我在谷歌浏览器中使用 demo.html 午餐时,我只得到一个白屏。
顶部截图 - demo.html 底部截图 - app.js
(function(){
var app = angular.module("myApp", []);
var direc = function()
{
return
{
restrict : 'A',
template : "<h1>Made by a directive!</h1>"
};
};
app.directive("w3TestDirective", direc);
})();
<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="app.js" type="text/javascript"></script>
<body ng-app="myApp">
<div w3-test-directive></div>
</body>
</html>
【问题讨论】:
标签: javascript html angularjs angularjs-directive