1. 程式人生 > >Angular.element 的用法

Angular.element 的用法

demo如下:

<html>

    <head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
        <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0" />



        <script type="text/javascript" src="js/angular.min.1.3.6.js"
>
</script> <!--<script type="text/javascript" src="js/angular.min-1.6.x.js"></script>--> <style> .alert-box{ width: 200px;height: 50px;background-color: aquamarine; } .alert-box2{ width: 200px
;height: 50px;background-color: red; }
</style> </head> <body ng-app='myapp1' ng-controller="customersCtrl"> <!--<enter>angularJs應用enter</enter> <leave >angularJs應用leave</leave>--> <div enter leave>
angularJs應用</div> <hello></hello> </body> <script type="text/javascript"> var app = angular.module('myapp1', []); app.controller('customersCtrl',function($scope){ console.log("控制器"); }); app.directive("enter",function(){ return function(scope,element,attrs){ console.log(element); element.bind('mouseenter',function(){ console.log('滑鼠移入進來了!!!'); element.addClass('alert-box'); }); } }); app.directive("leave",function(){ return function(scope,element,attrs){ console.log(element); element.bind('mouseleave',function(){ console.log('滑鼠移開了!!!'); element.removeClass('alert-box'); }); } }); app.directive("hello",function(){ return { restrict:'E', template:'<div><input type="text" ng-model="txt"/></div><div>{{txt}}</div>', link:function(scope,element){ scope.$watch('txt',function(newval){ console.log('監聽執行'); if (newval=='aaa') { element.addClass('alert-box2'); console.log('error執行'); } }); } } }); </script> </html>

相關推薦

ng-click得到當前元素,angular.element()用法

以下排版太亂,整理在此:點我<!DOCTYPE html> <html> <head> <title></title> <script src="lib/jquery/jquery-1.10.

Angular.element用法

demo如下: <html> <head> <meta http-equiv="content-type" content="text/html

AngularJS操作DOM——angular.element

number blog data htm lsp 元素 pad addclass 16px addClass()-為每個匹配的元素添加指定的樣式類名 after()-在匹配元素集合中的每個元素後面插入參數所指定的內容,作為其兄弟節點 append()-在每個匹配

angular.element方法匯總

上一個 所有 對象 篩選 hasclass clone 同時 con with addClass()-為每個匹配的元素添加指定的樣式類名after()-在匹配元素集合中的每個元素後面插入參數所指定的內容,作為其兄弟節點append()-在每個匹配元素裏面的末尾處插入參數內容

angular.element

bin moved dom元素 with 不支持 hand ren class html 將DOM元素或者HTML字符串一包裝成一個jQuery元素。 格式:angular.element(element); element:包裝成jquery對象的html字符串或者dom

Angular.forEach用法

1.針對物件迴圈(key,value) 官方示例: var values = {name: 'misko', gender: 'male'}; var log = []; angular.forEach(values, function(value, key) {

angular.element 的方法

addClass()-為每個匹配的元素新增指定的樣式類名 after()-在匹配元素集合中的每個元素後面插入引數所指定的內容,作為其兄弟節點 append()-在每個匹配元素裡面的末尾處插入引數內容 attr() - 獲取匹配的元素集合中的第一個元素的屬性的值 bind(

Angular.js用法(二):購物車數量加減及總價計算

1、下載後引入angular.min.js 2、程式碼如下: <h1>計算商品價格</h1> <div ng-app="buy" ng-controller="c

angular中的ng-options 用法

ng- -o value set lec html sel -m 選擇 <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title></title

angular-用法

-a https logs team des png github images 技術分享 一:參考腦圖https://github.com/TeamStuQ/skill-map/blob/master/data/designbyStuQ/png-Angular2-by-S

Angular 定時器$timeout和$interval關於定時刷新頁面和發送請求的用法

數值 事件 view sco 項目 span 檢查 delay .get 項目中有用到定時器定時刷新頁面的數據,在網上查看了一些資料,整理了一下,備忘。 $timeout 用法如下:$timeout(fn,[delay],[invokeApply]); fn:一個將被延遲

angular類似於vue的v-html的用法

<script> Angular將字符串輸出為HTML字符串vue:<div v-html=""newData.Contents"></div>anuglar:<div [innerHTML]="newData.Con

angular 的 @Input、@Output 的一個用法

script from console 做的 his temp http class child angular 使用 @input、@Output 來進行父子組件之間數據的傳遞。 如下: 父元素: <child-root parent_value="this

【vue】vue +element 搭建項目,this.$nextTick用法

搭建項目 any element http 項目 .cn .com 相關 .html 相關資料:https://www.cnblogs.com/leaf930814/p/7247478.html      https://www.

angular custom Element 自定義web component

als 強行 spa jquery app 我們 false 計算 大小 angular 自定義web組件: 首先創建一個名為myCustom的組件。 引入app.module: ... import {customComponent} from ‘ ./myCu

element ui Angular學習筆記(一)

5.1 har del align ger main offset 搜索 vertica 1.element ui安裝 npm i --save element-angular 2.Angular-cli引入 引入後需要開啟ElModule.forRoot(),也可以單獨引

angular中cookies的用法

sharp cookies AS har angularjs pre lib sha 封裝 AngularJs中對cookies的操作進行了單獨的封裝,首先需要先引入angular-cookies.js文件; <script src="scripts/lib/ang

element-ui使用導航欄跳轉路由用法

sta lang ring tis tty quick 發布項目 content console element-ui使用導航欄跳轉路由用法 最近初學vue,試著做一個小項目熟悉語法與思想,其中使用elemen-ui的導航欄做路由跳轉切換頁面。下面記錄一下

Angular——resolve基礎用法

參考Angular中文網 <Resolve: 預先獲取元件資料> API地址 <resolve守衛> 一、使用場景 resolve保證了資料獲取後再進行路由跳轉,防止因為資料延遲而出現短暫的空元件情況,以此增強使用者體驗。 應用resolve

簡述angular中constant和$filter的用法

這裡是修真院前端小課堂,每篇分享文從 【背景介紹】【知識剖析】【常見問題】【解決方案】【編碼實戰】【擴充套件思考】【更多討論】【參考文獻】 八個方面深度解析前端知識/技能,本篇分享的是: 【簡述angular中constant和$filter的用法】 【JS-7】簡述angula