【发布时间】:2015-07-01 14:43:13
【问题描述】:
我正在尝试实现 AngularJS 的自定义指令。
假设代码如下所示。
<!DOCTYPE html>
<html lang='en' ng-app='testApp'>
<head>
<meta charset='utf-8'/>
<meta http-equiv='X-UA-Compatible' content='IE=edge'/>
<meta name='viewport' content='width=device-width, initial-scale=1'/>
<script src="angular.js"></script>
<script src="searchinput.js"></script>
</head>
<body>
<searchInput></searchInput>
</body>
</html>
searchInput.js
var testApp = angular.module('testApp', []);
testApp.directive("searchInput", function() {
return {
replace:true,
restrict: 'AE',
template: '<h3>Hello World!!</h3>'
}
});
很遗憾,我没有看到预期的结果。有谁知道我错过了什么?谢谢。
【问题讨论】:
-
按照以下答案的指示进行操作。
标签: angularjs