【发布时间】:2014-03-11 14:39:52
【问题描述】:
我正在学习 Angular JS,并想创建我的自定义指令。 我的 javascript 代码没有显示任何错误,但自定义指令没有被我的 HTML 模板替换。 您能否指导如何调试此问题或此代码有什么问题? jsFiddle link
<body ng-controller="customdirectivecontroller">
<p>Placed custom directive here!</p>
<mytextbox></mytextbox>
</body>
------------------
var customdirectiveapp = angular.module('customdirectiveapp', []);
customdirectiveapp.controller = ('customdirectivecontroller', function ($scope, $http) {
$scope.name = "xxx";
});
customdirectiveapp.directive = ('mytextbox', function () {
var directive = {};
directive.restrict = 'E'; /* restrict this directive to elements */
directive.template = "My first directive: ";
return directive;
});
【问题讨论】: