emberJS
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<script src="http://localhost:81/js/jquery.min.js"></script>
<script src="http://localhost:81/js/handlebars.js"></script>
<script src="http://localhost:81/js/emberjs.js"></script>
</head>
<body>
<script>
function log(v){
console.warn(v)
}
var MyApp = {}; //demo1
MyApp.president = Ember.Object.create({
name: "Barack Obama"
}); MyApp.country = Ember.Object.create({
//presidentName = Ember.Binding(MyApp.president.name)
presidentNameBinding: 'MyApp.president.name'
}); log( MyApp.country.get('presidentName') ); //demo2
MyApp.president = Ember.Object.create({
firstName: "Barack",
lastName: "Obama",
fullName: function() {
return this.get('firstName') + ' ' + this.get('lastName');
// Tell Ember that this computed property depends on firstName
// and lastName
}.property('firstName', 'lastName')
});
log( MyApp.president.get('fullName') ); //demo3
//新建模型,模型拥有say方法;
var Person = Ember.Object.extend({
say: function(thing) {
alert(thing);
}
});
//实例化Person
//var person = Person.create();
//person.say("hello world"); var tom = Person.create({
name : "tom",
helloWorld : function(){
this.say("Hi " + this.get("name"))
}
});
//tom.helloWorld(); var yehuda = Person.create({
name : "qihao",
say : function(){
var name = this.get("name");
console.log( name )
//console.log( this._super() )
//this._super("hello"+name)
}
});
//yehuda.say() var loud = Person.extend({
say : function(thing){
//this._super有问题,不知道怎么回事;
//this._super(thing);
}
})
loud("nono"); /*
Person.reopen({
say : function(){
alert(1)
}
})
*/
//(new Person).say() </script>
<script type="text/x-handlebars">
The President of the United States is {{MyApp.president.fullName}}
</script>
</body>
</html>
emberJS的更多相关文章
- EmberJs之数组绑定@each&[]
写在前面 好长时间没有写博客了,昨天花了些时间又整理了下之前发布过的<Ember.js之computed Property>文章,并创建了一个测试代码库,花了些时间,希望能使用测试代码的方 ...
- Emberjs之ComputedProperty
计算属性,以下简称CP.简单概括来讲,就是在需要属性值的时候计算一个Function,并将Function返回的值保存在属性中,当第二次获取属性值时,如果发现属性并未改变则直接读取属性,如果属性依赖的 ...
- emberjs学习二(ember-data和localstorage_adapter)
emberjs学习二(ember-data和localstorage_adapter) 准备工作 首先我们加入ember-data和ember-localstorage-adapter两个依赖项,使用 ...
- emberjs学习一(环境和第一个例子)
code { margin: 0; padding: 0; white-space: pre; border: none; background: transparent; } code, pre t ...
- EmberJs之使用Ember-Data
写在前面 最近比较忙,换了新工作还要学习很多全新的技术栈,并给自己找了很多借口来不去坚持写博客.常常具有讽刺意味的是,更多剩下的时间并没有利用而更多的是白白浪费,也许这就是青春吧,挥霍吧,这不是我想要 ...
- EmberJs之3W
写在前面 最近比较忙,换了新工作还要学习很多全新的技术栈,并给自己找了很多借口来不去坚持写博客.常常具有讽刺意味的是,更多剩下的时间并没有利用而更多的是白白浪费,也许这就是青春吧,挥霍吧,这不是我想要 ...
- emberjs初学记要
code { margin: 0; padding: 0; white-space: pre; border: none; background: transparent; } code, pre t ...
- quora 中有关angular与emberjs的精彩辩论
原贴地址,要注册才能看,这里只有国人翻译的一部分内容 本文源自于Quora网站的一个问题,作者称最近一直在为一个新的Rails项目寻找一个JavaScript框架,通过筛选,最终纠结于Angular. ...
- d3 js emberjs handlerbarjs
http://handlebarsjs.com/ http://emberjs.com/ http://jsbin.com/d3ember-barchart/13/edit?html,output
随机推荐
- uva 839 not so mobile——yhx
Not so Mobile Before being an ubiquous communications gadget, a mobile was just a structure made of ...
- Windows事件ID大全
51 Windows 无法找到网络路径.请确认网络路径正确并且目标计算机不忙或已关闭.如果 Windows 仍然无法找到网络路径,请与网络管理员联系. 52 由于网络上有重名,没有连接.请到“控制面板 ...
- codeforces 477B B. Dreamoon and Sets(构造)
题目链接: B. Dreamoon and Sets time limit per test 1 second memory limit per test 256 megabytes input st ...
- UESTC 288 青蛙的约会 扩展GCD
设两只青蛙跳了t步,则此时A的坐标:x+mt,B的坐标:y+nt.要使的他们在同一点,则要满足: x+mt - (y+nt) = kL (p是整数) 化成: (n-m)t + kL = x-y (L ...
- np问题
NP(np) Time Limit:1000ms Memory Limit:64MB 题目描述 LYK 喜欢研究一些比较困难的问题,比如 np 问题.这次它又遇到一个棘手的 np 问题.问题是这个样子 ...
- Jenkins学习七:Jenkins的授权和访问控制
默认的Jenkins不包含任何的安全检查,任何人可以修改Jenkins设置,job和启动build等.显然地在大规模的公司需要多个部门一起协调工作的时候,没有任何安全检查会带来很多的问题. 在系统管理 ...
- java 11-7String类里的方法的一些案例
1. 把int数组拼接成字符串的案例 需求:把数组中的数据按照指定个格式拼接成一个字符串 举例: int[] arr = {1,2,3}; 分析: A:首先定义一个空的字符串 B:其次先给这个字符串拼 ...
- cocoaPod相关问题
cocoap简介: 1. 简介 CocoaPods是一个负责管理iOS项目中第三方开源代码的工具,其源码在Github上开源.使用CocoaPods可以节省设置和更新第三方开源库的时间并提高工作效率. ...
- html2canvas手机端模糊问题
待解决.测试对于图片之类的没有影响.但是文字在手机上看起来比较模糊.
- Linux 进程通信(有名管道)
有名管道(FIFO) 有名管道是持久稳定的. 它们存在于文件系统中. FIFO比无名管道作用更大,因为他们能让无关联的进程之间交换数据. 管道文件一般用于交换数据. shell命令创建管道 一个she ...