博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Angularjs 事件指令
阅读量:7045 次
发布时间:2019-06-28

本文共 1556 字,大约阅读时间需要 5 分钟。

1.  点击事件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<!
DOCTYPE 
html>
<
html
>
<
head
>
    
<
meta 
http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
<
title
>无标题文档</
title
>
    
<
script 
type="text/javascript" src="angular.min.js"></
script
>
</
head
>
<
body
>
<
div 
ng-app="myApp">
 
    
<
div 
ng-controller="firstController">
        
<
div 
ng-click="run()">点击</
div
>
    
</
div
>
</
div
>
<
script 
type="text/javascript">
    
var app = angular.module("myApp", []);
    
app.controller('firstController',function($scope){
        
$scope.text='phonegap中文网';
 
        
$scope.run=function(){
 
            
alert('run');
            
console.log('run');
        
}
    
});
</
script
>
 
</
body
>
</
html
>

  

 

2. 样式 ng-class

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<!
DOCTYPE 
html>
<
html
>
<
head
>
    
<
meta 
http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
<
title
>无标题文档</
title
>
    
<
script 
type="text/javascript" src="angular.min.js"></
script
>
    
<
style
>
        
.red{background:red;}
        
.yellow{background:yellow;}
    
</
style
>
</
head
>
<
body
>
<
div 
ng-app="myApp">
 
    
<
div 
ng-controller="firstController">
        
<
div 
ng-click="run()">点击</
div
>
        
<
div 
ng-class="{red:true}">{
{text}}</
div
>
    
</
div
>
</
div
>
<
script 
type="text/javascript">
    
var app = angular.module("myApp", []);
    
app.controller('firstController',function($scope){
        
$scope.text='phonegap中文网';
 
        
$scope.run=function(){
 
            
alert('run');
            
console.log('run');
        
}
    
});
</
script
>
 
</
body
>
</
html
>

  

本文转自Work Hard Work Smart博客园博客,原文链接:http://www.cnblogs.com/linlf03/p/7137758.html,如需转载请自行联系原作者

你可能感兴趣的文章
Android防止进程被第三方软件杀死
查看>>
PostgreSQL在何处处理 sql查询之四十九
查看>>
ASP.NET Core 使用 Redis 客户端
查看>>
基础才是重中之重~stream和byte[]的概念与转化
查看>>
[LeetCode] Distribute Candies 分糖果
查看>>
【Android错误集锦】Could not resolve net.qiujuer.genius:kit-handler:latest.integration.
查看>>
CTF---Web入门第十四题 忘记密码了
查看>>
十天学会Div+CSS之第一天
查看>>
6.3. Pyrus
查看>>
[Spring MVC] - JSP + Freemarker视图解释器整合(转)
查看>>
POJ1023 The Fun Number System
查看>>
第 41 章 TokyoCabinet/Tyrant
查看>>
8.4. whiptail - display dialog boxes from shell scripts
查看>>
Educational Codeforces Round 21 D.Array Division(二分)
查看>>
Android 中文API (32) —— TimePicker.OnTimeChangedListener
查看>>
如何修改路由器的登录IP地址?
查看>>
外观(Facade)模式
查看>>
Building Android Apps 30条建议
查看>>
【Spring实战】—— 13 AspectJ注解切面
查看>>
Java 集合并交补
查看>>