search

Home  >  Q&A  >  body text

angular.js - angularJS ng-style用法

angularJS ng-style usage thank you

phpcn_u1582phpcn_u15822817 days ago834

reply all(1)I'll reply

  • phpcn_u1582

    phpcn_u15822017-05-15 17:00:40

    The

    ng-style directive corresponds to a key-value pair composed of CSS attributes. It is an object and adds the corresponding style to the corresponding element. The following is an example given in the Angular API document. The document address is https://docs. angularjs.org/api/ng/directive/ngStyle You may need to circumvent the firewall, or you can read the explanation of the novice tutorial http://www.runoob.com/angularjs/ng-ng-style.html

    <input type="button" value="set color" ng-click="myStyle={color:'red'}">
    <input type="button" value="set background" ng-click="myStyle={'background-color':'blue'}">
    <input type="button" value="clear" ng-click="myStyle={}">
    <br/>
    <span ng-style="myStyle">Sample Text</span>
    <pre>myStyle={{myStyle}}</pre>

    reply
    0
  • Cancelreply