【发布时间】:2015-01-07 14:58:01
【问题描述】:
试图做一些 DOM 操作,但 link() 从未被调用,所以没有任何反应:
app.js
var app = angular.module('app', ['directives', ...]);
var directives = angular.module('directives', []);
...
directives.js
directives.directive('doIt', ['$window', function($window) {
return {
restrict: 'A',
link: function(scope, element, attrs) {
console.log('Inside link()');
// Do stuff with $window
}
};
]});
HTML
<html ng-app="app">
<body>
<div ng-view>
<div do-it>
// ....
</div>
</div>
</body>
</html>
我错过了什么?
【问题讨论】:
标签: javascript angularjs angularjs-directive dom-manipulation