我正在尝试创建指令,但是我的指令函数没有被调用。
index.html
<div ng-repeat="que in questions.Cars">
<question-dir>print from direcetive</question-dir>
</div>
ConytrolDirective.js
(function () {
"use strict";
angular
.module("autoQuote")
.directive('questionDir',["questionDir"] );
function questionDir()
{
return {
template : "<h1>Made by a directive!</h1>"
};
}
}());
最佳答案
您的代码中有几个错误。
"questionDir"
.directive('questionDir',[questionDir] );
-
分隔的单词)`<question-dir>print from direcetive</question-dir>`
<script src="controlDirectives.js"></script>
。 Demo here