ng-init,ng-controller,ng-model
1.ng-init
用于初始化数据,跟在$scope插入数据一样,但是在配合repeat指令时候比较有用:
<div ng-repeat="arrOuter in arr" ng-init="outerIndex = $index">
<div ng-repeat="arrInner in arrOuter" ng-init="innerIndex = $index">
<p>{{arrInner}}:{{outerIndex}}{{innerIndex}}</p>
</div>
</div>
2.ng-controller
当controller里面的回调是一个对象的写法的时候。如:
1.controller('Aaa',['$scope',FnAaa]);
function FnAaa($scope){
}
FnAaa.prototype.num = '123';
那ng-controller指令的用法就得这样写了
<div ng-controller="FnAaa as a1">
<div>{{a1.text}}:{{a1.show()}}</div>
</div>
这里的a1就是创建的一个FnAaa对象。
3.ng-model
这个指令用于双向数据绑定,之前就用在输入框里面,
可以通过ng-model-options来配置触发数据变化的事件。
<input type="text" ng-model="text" ng-model-options="{updateOn : 'blur'}">
ng-init,ng-controller,ng-model的更多相关文章
- 不知道张(zhāng)雱(pāng)是谁?你out了!
张(zhāng)雱(pāng)是谁?也许你已经听说过了,也许你还没听说过呢,不过你一定听说过老刘——刘强东,没错,这二人是有关系的,什么关系,京东是老刘的,而张雱呢?张雱是京东旗下52家关联公司法人代 ...
- Go语言之高级篇beego框架之controller调用model
一.controller调用model 开发规范,就该把对数据库的操作写在model文件夹中. 示例: views/main.go package main import ( _ "web/ ...
- Java Web中的mapper,service,controller,model
Java Web中的mapper,service,controller,model作用分别是:java web中mapper是对象持久化映射层,一般会继承ibatis或者mybatisservive是 ...
- Part 15 AngularJS ng init directive
The ng-init directive allows you to evaluate an expression in the current scope. In the following e ...
- ng build --aot 与 ng build --prod
angluar的编译有以下几种方式: ng build 常规的压缩操作 代码体积最大 ng build --aot angular预编译 代码体积较小 ng build --pr ...
- ASP.NET MVC系列:从Controller访问Model数据
在项目解决方案中,添加一个MoviesController控制器,选择对应的模板,和模型类以及数据上下文:关于如何添加模型类和数据上下文,我们在ASP.NET MVC系列:添加模型中已经介绍过
- Controller将Model数据传给View层,View层应该如何处理?
首先,我们在Model层中添加一个Person类. namespace MVCTest.Models{ public class Person { public string ...
- rails 创建项目、创建controller、model等
rails2之前创建新项目: rails3以及更高版本创建新项目:rails new webname 创建数据表model:rails g model user name:string sex:str ...
- CodeIgniter 定义“全局变量-global variable”,可以在所有controller,model和view中使用
本文抄自http://www.cnblogs.com/webu/archive/2012/11/20/2779999.html 第一次正儿八经用CodeIgniter框架做项目,结果不会定义全局变量, ...
- Laravel 中 Controller访问Model函数/常量
<?php // User.php class User extends Model { ; //进行中 const USER_TYPE_TEST = 'test'; //测试用户 // 需要在 ...
随机推荐
- C++小常识笔记
1.C++的继承保护级别最好是显示的写出来.(注:class 的默认继承为private,struct的默认继承为public). 例: class Base{/**/}; struct D1 : B ...
- sea.js 入门
上个月学了 require.js 现在顺便来学学 sea.js. 对比下这两种的区别,看自己喜欢哪个,就在接下来的项目中去使用它吧. seajs中的所有 JavaScript 模块都遵循 CMD 模块 ...
- Kafka报错-as it has seen zxid 0x83808 our last zxid is 0x0 client must try another server
as it has seen zxid 0x83808 our last zxid is 0x0 client must try another server 停止zookeeper,删除datadi ...
- C++:名字查找先于类型检查
Sub-Title: Name Hiding. "In C++, there is no overloading across scopes - derived class scopes a ...
- private + virtual in Java/C++
在Java中,private方法是隐式final的,就是说即使在子类中定义一个一模一样的方法,编译器认为这是两个没有联系的方法.private方法不参与运行时多态,这点和 final方法.static ...
- @MappedSuperclass注解的使用说明
转载自:http://blog.sina.com.cn/s/blog_7085382f0100uk4p.html 基于代码复用和模型分离的思想,在项目开发中使用JPA的@MappedSuperclas ...
- Java Annotation 注解
java_notation.html div.oembedall-githubrepos { border: 1px solid #DDD; list-style-type: none; margin ...
- Node.js 中MongoDB的基本接口操作
Node.js 中MongoDB的基本接口操作 连接数据库 安装mongodb模块 导入mongodb模块 调用connect方法 文档的增删改查操作 插入文档 方法: db.collection(& ...
- Java数组的一些基本算法
数组的一些算法问题: 排序:(升序) 选择排序: 求每一轮的最小值:再输出 冒泡排序: 相邻的两个数相比较,把两个数相比较,第一个大于好面的就交换位置 shell排序: ...
- js中的tostring()方法
http://blog.sina.com.cn/s/blog_85c1dc100101bxgg.html js中的tostring()方法 (2013-11-12 11:07:43) 转载▼ 标签: ...