Expand Minimize

Use built-in AngularJS directives whenever possible

Use built-in AngularJS directives whenever possible to ensure that markup remains valid

CheckId NG1011001
TypeName UseBuiltInAngularJsDirectivesWheneverPossible
Severity CriticalWarning
Type Template

When passing dynamic values into attributes, you should use built-in AngularJS directives such as ng-src, ng-href or ng-style instead of their HTML equivalents. Using the built-in AngularJS directives, helps you ensure that the markup will remain valid, even if the dynamic value isn't available yet. Additionally, these directives are well-written and tested.

Good practice

<div ng-controller="MainCtrl as main">
    <div ng-style="main.divStyle">my beautifully styled div which will work in IE</div>
</div>


Bad practice
<div ng-controller="MainCtrl as main">
    <div style="{{main.divStyle}}">my beautifully styled div which will work in IE</div>
</div>

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.