Angular学习(4)- 数组双向梆定
示例:
<!DOCTYPE html>
<html ng-app="MyApp">
<head>
<title>Study 4</title>
<script type="text/javascript" src="js/angular.js"></script>
</head>
<body>
<div ng-controller="testController">
<h1>{{model.newTitle}}</h1>
Name:<input type="text" ng-model="model.name" />
Fraction:<input type="text" ng-model="model.fraction" />
<input type="button" ng-click="add(model.fraction)" value="Add" />
<ul>
<li ng-repeat="item in model.options">
<b>{{$index+1}}</b>
<input type="text" ng-model="item.content" value="item.content" />
<a href="javascript:void(0)" ng-click="del($index)">Delete</a>
</li>
</ul>
<hr />
<div>
<h1>{{model.previewTitle}}</h1>
<b>{{model.name}}</b>({{model.fraction}})
<ul>
<li ng-repeat="item in model.options">
<b>{{$index + 1}}</b>
<input type="radio" name="rdCheck" />
{{item.content}}
</li>
</ul>
</div>
</div>
<script type="text/javascript">
var app = angular.module("MyApp", [], function() { });
var myModel = {
newTitle: "Title",
previewTitle: "Preview Title",
name: "Robin",
fraction: "100",
options: []
};
app.controller("testController", function($scope) {
$scope.model = myModel;
$scope.add = function(text) {
var obj = { content: text };
$scope.model.options.push(obj);
};
$scope.del = function(index) {
$scope.model.options.splice(index, 1);
};
});
</script>
</body>
</html>
Angular学习(4)- 数组双向梆定的更多相关文章
- Angular学习(6)- 数组双向梆定+filter+directive
示例: <!DOCTYPE html> <html ng-app="MyApp"> <head> <title>Study 6< ...
- Angular学习(5)- 数组双向梆定+filter
示例: <!DOCTYPE html> <html ng-app="MyApp"> <head> <title>Study 5< ...
- Angular学习(3)- 双向梆定
示例代码: <!DOCTYPE html> <html ng-app="MyApp"> <head> <title>Study 3& ...
- angular学习笔记(三十一)-$location(2)
之前已经介绍了$location服务的基本用法:angular学习笔记(三十一)-$location(1). 这篇是上一篇的进阶,介绍$location的配置,兼容各版本浏览器,等. *注意,这里介绍 ...
- Angular学习资料大全和常用语法汇总(让后端程序员轻松上手)
前言: 首先为什么要写这样的一篇文章呢?主要是因为前段时间写过一些关于Angualr的相关实战文章,有些爱学习的小伙伴对这方面比较感兴趣,但是又不知道该怎么入手(因为认识我的大多数小伙伴都是后端的同学 ...
- angular学习笔记(三十一)-$location(1)
本篇介绍angular中的$location服务的基本用法,下一篇介绍它的复杂的用法. $location服务的主要作用是用于获取当前url以及改变当前的url,并且存入历史记录. 一. 获取url的 ...
- angular学习笔记(三十)-指令(10)-require和controller
本篇介绍指令的最后两个属性,require和controller 当一个指令需要和父元素指令进行通信的时候,它们就会用到这两个属性,什么意思还是要看栗子: html: <outer‐direct ...
- angular学习笔记(三十)-指令(7)-compile和link(2)
继续上一篇:angular学习笔记(三十)-指令(7)-compile和link(1) 上一篇讲了compile函数的基本概念,接下来详细讲解compile和link的执行顺序. 看一段三个指令嵌套的 ...
- angular学习笔记(三十)-指令(6)-transclude()方法(又称linker()方法)-模拟ng-repeat指令
在angular学习笔记(三十)-指令(4)-transclude文章的末尾提到了,如果在指令中需要反复使用被嵌套的那一坨,需要使用transclude()方法. 在angular学习笔记(三十)-指 ...
随机推荐
- 【Better Code】repeat
<JavaScript 框架设计> 版本1: function repeat(target, n) { return (new Array(n + 1)).join(target) } 版 ...
- Think Python - Chapter 16 - Classes and functions
16.1 TimeAs another example of a user-defined type, we’ll define a class called Time that records th ...
- matplotlib example
# This file generates an old version of the matplotlib logofrom __future__ import print_function# Ab ...
- Welcome to MacJournal!
Welcome to MacJournal 6 To get started, create a new entry by clicking on "New Entry" in t ...
- boot/bootsect.S
!! SYS_SIZE is the number of clicks (16 bytes) to be loaded.! 0x7F00 is 0x7F000 bytes = 508kB, more ...
- HDU 1312 Red and Black --- 入门搜索 BFS解法
HDU 1312 题目大意: 一个地图里面有三种元素,分别为"@",".","#",其中@为人的起始位置,"#"可以想象 ...
- 越狱Season 1-Episode 4: Cute Poison
Season 1, Episode 4: Cute Poison [Previously on Prison Break] previously: 以前地 前情提要 -Burrows: I didn' ...
- Java——File(文件)
public static void main(String[] args) { // getFile(); /* * 需求: 对指定目录进行所有内容的列出,(包含子目录中的内容) * */ ...
- MySQL Backup in Facebook
本文将较为详细的介绍Facebook对于MySQL数据库的备份策略和方法 文章欢迎转载,但转载时请保留本段文字,并置于文章的顶部 作者:卢钧轶(cenalulu) 本文原文地址:http://cena ...
- XunSearch(讯搜)的使用教程步骤
一.安装编译工具 yum install make gcc g++ gcc-c++ libtool autoconf automake imake mysql-devel libxml2-devel ...