zoukankan      html  css  js  c++  java
  • angularjs教程——样式相关指令详解

    一、ng-class

    <!DOCTYPE HTML>
    <html ng-app='myApp'>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script src="angular.min.js"></script>
    <style type="text/css">
    .red{ background:red;}
    .yellow{ color:yellow;}
    </style>
    <script>
    var m1=angular.module('myApp',[]);
    
    m1.controller('Aaa',['$scope',function($scope){
      $scope.text='hellow';
      
    }]);
    
    </script>
    <title>无标题文档</title>
    </head>
    
    <body>
    <div ng-controller="Aaa">
      <div ng-class="{red:true,yellow:true}">{{text}}</div>
    </div>
    </body>
    </html>

    二、ng-style

    <!DOCTYPE HTML>
    <html ng-app='myApp'>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script src="angular.min.js"></script>
    <style type="text/css">
    .red{ background:red;}
    .yellow{ color:yellow;}
    </style>
    <script>
    var m1=angular.module('myApp',[]);
    
    m1.controller('Aaa',['$scope',function($scope){
      $scope.text='hellow';
      
    }]);
    
    </script>
    <title>无标题文档</title>
    </head>
    
    <body>
    <div ng-controller="Aaa">
      <div ng-style="{background:'red',color:'yellow'}">{{text}}</div>
    </div>
    </body>
    </html>
    View Code
    <!DOCTYPE HTML>
    <html ng-app='myApp'>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script src="angular.min.js"></script>
    <style type="text/css">
    .red{ background:red;}
    .yellow{ color:yellow;}
    </style>
    <script>
    var m1=angular.module('myApp',[]);
    
    m1.controller('Aaa',['$scope',function($scope){
      $scope.text='hellow';
      $scope.style="{background:'red',color:'yellow'}"
      
    }]);
    
    </script>
    <title>无标题文档</title>
    </head>
    
    <body>
    <div ng-controller="Aaa">
      <div ng-style="{{style}}">{{text}}</div>
    </div>
    </body>
    </html>
    View Code

    三、ng-href、ng-src、ng-attr-(suffix)

  • 相关阅读:
    C# richTextBox封装的一个打印的类
    RichtextBox打印
    RichTextBox选中文本时往自己的其他的位置实现拖拽
    C# 保存和读取TreeView展开的状态
    RichtextBox去除闪烁光标
    自己重启自己
    记录一次shell里局部变量的问题
    Redis配置总结
    Nginx原理和配置总结
    CentOS7+Nginx+多个Tomcat配置
  • 原文地址:https://www.cnblogs.com/cacti/p/5953428.html
Copyright © 2011-2022 走看看