zoukankan      html  css  js  c++  java
  • Angular常用功能

    1.默认选择让第0个元素的class为active

    ng-class="{active:$index == 0}"

    2.指令的例子

    <!DOCTYPE html>
    <html ng-app="test">
    <head>
    <meta charset="utf-8" />
    <title></title>
    <style type="text/css">
    
    </style>
    </head>
    <body ng-controller="helloCtrl">
    
    
    <expander class="expander" expander-title="title" expander-content="content"></expander>
    
    
    <script src="scripts/lib/angular.min.js"></script>
    <script>
    angular.module('test',[])
    
    .directive('expander',function (){
    
    return {
    
    restrict:'EA',
    replace : true,
    transclude : true,
    scope : {
    
    title : '=expanderTitle',
    content : '=expanderContent'
    },
    template : '<div>'
    + '<div class="title" ng-click="toggle()">{{title}}</div>'
    + '<div class="body" ng-show="showMe">{{content}}</div>'
    + '</div>',
    
    link : function (scope,element,attrs){
    
    scope.showMe = false;
    scope.toggle = function (){
    
    scope.showMe = !scope.showMe;
    }
    }
    }
    })
    
    .controller('helloCtrl',function ($scope){
    
    $scope.title = '标题';
    $scope.content = '内容';
    })
    </script>
    </body>
    </html>
    

      

  • 相关阅读:
    刻意练习:从一般到卓越的方法
    Spring JMS 整合 ActiveMQ
    冒泡排序 快速排序
    TCP协议,UDP 协议的区别
    HashMap实现原理
    java 类加载过程
    Linux-vim命令(3)
    Linux-vim命令(2)
    Linux-vim命令(1)
    Linux-命令里的快捷键
  • 原文地址:https://www.cnblogs.com/SmileCN/p/3425063.html
Copyright © 2011-2022 走看看