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)

  • 相关阅读:
    ecshop里的$_CFG从哪来的
    高效PHP程序必知的53个技巧
    Jquery结合datagrid框架
    PHP数据类型转换(字符转数字,数字转字符)
    php 操作数组 (合并,拆分,追加,查找,删除等)
    css3制作导航栏
    php日期转时间戳,指定日期转换成时间戳
    PHP 时间与字符串的相互转化
    php 生成.txt文件
    linux PHP yum 安装phpzie
  • 原文地址:https://www.cnblogs.com/cacti/p/5953428.html
Copyright © 2011-2022 走看看