Don't manipulate DOM in controllers |
Don't manipulate DOM in controllers as the HTML hasn't been fully rendered yet
CheckId | NG1010401 |
---|---|
TypeName | DontManipulateDomInControllers |
Severity | CriticalWarning |
Type | Controller |
You shouldn't be modifying or accessing DOM in AngularJS controllers. When controllers run, the DOM might not be fully rendered yet which could cause your code to run incorrectly. If you need to access the DOM, you should build a component or a directive instead.
Bad practice
angular.module('app').controller('HomeController', function() {
$(".search-details-form").hide();
});
$(".search-details-form").hide();
});
Disclaimer: The views and opinions expressed in this documentation and in SPCAF do not necessarily reflect the opinions and recommendations of Microsoft or any member of Microsoft. SPCAF and RENCORE are registered trademarks of Rencore. All other trademarks, service marks, collective marks, copyrights, registered names, and marks used or cited by this documentation are the property of their respective owners.