12
Hãy nói rằng tôi có:AngularJS element.innerHTML là undefined từ bên trong chỉ thị
directives.directive('foo', function() {
return {
restrict:'A',
scope: true,
link:function (scope, element, attr) {
console.log('innerHTML is ' + element.innerHTML);
scope.$watch('update', function (newValue) {
console.log('innerHTML is... ' + element.innerHTML);
});
}
}
});
... sau đó innerHTML là undefined. Tôi tưởng tượng điều này là do cách mà Angular xử lý DOM. Cách đúng để có được innerHTML là gì?
Cảm ơn bạn. Chính xác những gì tôi đã mất tích. –