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)

  • 相关阅读:
    fedora 20 安裝 及 配置桌面環境
    2014上半年—Linux操作系统—嵌入式开发—中考
    【hdu 1864】最大报销额
    【hdu 1067】Gap
    【t055】成绩统计
    【b094&&z14】靶形数独
    【z06】观光公交
    【u213&&t037】修剪花卉
    【t062】最厉害的机器人
    【t075】郁闷的记者
  • 原文地址:https://www.cnblogs.com/cacti/p/5953428.html
Copyright © 2011-2022 走看看