Tôi đã dành chút thời gian để tìm bất kỳ tài liệu nào cho $ element nhưng havent có thể tìm thấy bất kỳ tài liệu chính thức nào trong angulars.
$element
là một trong bốn người dân địa phương mà $compileProvider
ban cho $controllerProvider
mà sau đó được trao cho $injector
. Các vòi phun tiêm người dân địa phương trong chức năng điều khiển của bạn chỉ khi được hỏi.
Bốn người dân địa phương là:
$scope
$element
$attrs
$transclude
Các tài liệu chính thức: AngularJS $compile Service API Reference - controller
Mã nguồn từ Github angular.js/compile.js:
function setupControllers($element, attrs, transcludeFn, controllerDirectives, isolateScope, scope) {
var elementControllers = createMap();
for (var controllerKey in controllerDirectives) {
var directive = controllerDirectives[controllerKey];
var locals = {
$scope: directive === newIsolateScopeDirective || directive.$$isolateScope ? isolateScope : scope,
$element: $element,
$attrs: attrs,
$transclude: transcludeFn
};
var controller = directive.controller;
if (controller == '@') {
controller = attrs[directive.name];
}
var controllerInstance = $controller(controller, locals, true, directive.controllerAs);