angularjs ng-switch

<p>
<a href="#" ng-click="toggle()">Toggle Section</a>
</p> <div ng-switch="section"> <p ng-switch-when="happy" bn-directive>
Oh sweet!
</p> <p ng-switch-when="sad" bn-directive>
Oh noes!
</p> </div>

js

var app = angular.module( "Demo", [] );
// 定义控制器
app.controller(
"DemoController",
function( $scope ) {
$scope.section = "happy";
//在toggle函数中改变section的值,以此在标记中显示/隐藏不同的部分
$scope.toggle = function() {
if ( $scope.section === "happy" ) {
$scope.section = "sad";
} else {
$scope.section = "happy";
}
};
}
);
angularjs ng-switch的更多相关文章
- Part 6 AngularJS ng repeat directive
ng-repeat is similar to foreach loop in C#. Let us understand this with an example. Here is what we ...
- part 4 AngularJS ng src directive
- Part 15 AngularJS ng init directive
The ng-init directive allows you to evaluate an expression in the current scope. In the following e ...
- [AngularJS] AngularJS系列(1) 基础篇
目录 什么是AngularJS? 为什么使用/ng特性 Hello World 内置指令 内置过滤器 模块化开发 一年前开始使用AngularJS(以后简称ng),如今ng已经出2了.虽说2已完全变样 ...
- 从angularJS看MVVM
javascript厚积薄发走势异常迅猛,导致现在各种MV*框架百家争雄,MVVM从MVC演变而来,为javascript注入了全新的活力.我工作的业务不会涉及到angularJS[ng]这么重量级的 ...
- angularJS看MVVM
从angularJS看MVVM javascript厚积薄发走势异常迅猛,导致现在各种MV*框架百家争雄,MVVM从MVC演变而来,为javascript注入了全新的活力.我工作的业务不会涉及到a ...
- js架构设计模式——从angularJS看MVVM
javascript厚积薄发走势异常迅猛,导致现在各种MV*框架百家争雄,MVVM从MVC演变而来,为javascript注入了全新的活力.我工作的业务不会涉及到 angularJS[ng] 这么重量 ...
- java 基础知识六 字符串2
java 基础知识六 字符串2 1.String类是final类,也即意味着String类不能被继承,并且它的成员方法都默认为final方法 . String 是不可变对象,也就是一旦创建,那么整 ...
- .Net Core应用框架Util介绍(一)
距离上次发文,已经过去了三年半,这几年技术更新节奏异常迅猛,.Net进入了跨平台时代,前端也被革命性的颠覆. 回顾 2015年,正当我还沉迷于JQuery + EasyUi的封装时,突然意识到技术已经 ...
- neo1973 audio subsystem
fhttp://wiki.openmoko.org/wiki/Neo_1973_audio_subsystem using Bluetooth headset with GSM NOTE none o ...
随机推荐
- 【第四篇】androidEventbus源代码阅读和分析
1,分析androidEventbus的注册源代码: 我们在使用androidEventbus的第一步是注册eventbus,如下代码: EventBus.getDefault().register( ...
- VBS虚拟键码
1 VK_LBUTTON 鼠标左键 2 VK_RBUTTON 鼠标右键 3 VK_CANCEL Ctrl+Break(通常不需要处理) 4 VK_MBUTTON 鼠标中键 8 VK_BACK Back ...
- C#连接Oracle的方法
C#连接Oracle的方法 方法1: System.Data.OracleClient oracleConnectionString : data source = orcl;user id= sco ...
- Linux KVM 安装配置
--------------------------一.前言二.环境三.安装与配置四.创建kvm虚拟机 一.前言 KVM,即Kernel-based Virtual Machine的简称,是一个开源的 ...
- UICollectionView之自定义Layout
#import <UIKit/UIKit.h> @interface WQViewController : UIViewController - (id)initWithFrame:(CG ...
- Java 反射实例
实体类:Userpackage com.reflect.model; public class User{ private User(int id, String username, String p ...
- Android PopupWindow菜单
初学Android,引用了这篇文章的代码 http://www.cnblogs.com/jiezzy/archive/2012/08/15/2640584.html 使用PopupWindow制作自定 ...
- js连续赋值、指针
jq的源码中有很多连续赋值,类似这样的: var a = {n:1}; var b = a; // 持有a,以回查 a.x = a = {n:2}; alert(a.x);// --> unde ...
- git 提交到github时不用每次都输入用户名,密码
Permanently authenticating with Git repositories, Run following command to enable credential caching ...
- js获取当前日期与星期
var currentDate = new Date(); var weekday = ["星期日", "星期一", "星期二", &quo ...