发布于 2017-06-14 08:54:35 | 156 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的AngularJS开发指南,程序狗速度看过来!

AngularJS 前端JS框架

AngularJS诞生于Google是一款优秀的前端JS框架,已经被用于Google的多款产品当中。AngularJS有着诸多特性,最为核心的是:MVC、模块化、自动化双向数据绑定、语义化标签、依赖注入,等等。


这篇文章主要介绍了AngularJS使用ng-class动态增减class样式的方法,结合具体实例形式分析了ng-class操作页面class样式的相关技巧,需要的朋友可以参考下

本文实例讲述了AngularJS使用ng-class动态增减class样式的方法。分享给大家供大家参考,具体如下:

使用ng-class可以实现动态地增减样式:


<!DOCTYPE html>
<html ng-app="formExample">
<head>
  <meta charset="UTF-8">
  <title></title>
  <script src="../js/angular.js"></script>
  <script>
    angular.module('formExample', [])
        .controller('FormController', ['$scope', function($scope)
        {
        }]);
  </script>
  <style>
    .strike {
      text-decoration: line-through;
    }
    .bold {
      font-weight: bold;
    }
    .red {
      color: red;
    }
  </style>
</head>
<body>
<div>
  <p ng-class="{strike: deleted, bold: important, red: error}">通过映射的方式</p>
  <input type="checkbox" ng-model="deleted">添加strike样式<br>
  <input type="checkbox" ng-model="important">添加bold样式<br>
  <input type="checkbox" ng-model="error">添加错误样式
  <hr>
  <p ng-class="style">使用字符串的方式</p>
  <input type="text" ng-model="style" placeholder="输入 bold、 strike 或 red">
  <hr>
  <p ng-class="[style1, style2, style3]">使用数组的方式</p>
  <input ng-model="style1" placeholder="输入: bold, strike 或 red"><br>
  <input ng-model="style2" placeholder="输入: bold, strike 或 red"><br>
  <input ng-model="style3" placeholder="输入: bold, strike 或 red"><br>
  <hr/>
</div>
</body>
</html>

希望本文所述对大家AngularJS程序设计有所帮助。



最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务