<!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的更多相关文章

  1. EmberJs之数组绑定@each&[]

    写在前面 好长时间没有写博客了,昨天花了些时间又整理了下之前发布过的<Ember.js之computed Property>文章,并创建了一个测试代码库,花了些时间,希望能使用测试代码的方 ...

  2. Emberjs之ComputedProperty

    计算属性,以下简称CP.简单概括来讲,就是在需要属性值的时候计算一个Function,并将Function返回的值保存在属性中,当第二次获取属性值时,如果发现属性并未改变则直接读取属性,如果属性依赖的 ...

  3. emberjs学习二(ember-data和localstorage_adapter)

    emberjs学习二(ember-data和localstorage_adapter) 准备工作 首先我们加入ember-data和ember-localstorage-adapter两个依赖项,使用 ...

  4. emberjs学习一(环境和第一个例子)

    code { margin: 0; padding: 0; white-space: pre; border: none; background: transparent; } code, pre t ...

  5. EmberJs之使用Ember-Data

    写在前面 最近比较忙,换了新工作还要学习很多全新的技术栈,并给自己找了很多借口来不去坚持写博客.常常具有讽刺意味的是,更多剩下的时间并没有利用而更多的是白白浪费,也许这就是青春吧,挥霍吧,这不是我想要 ...

  6. EmberJs之3W

    写在前面 最近比较忙,换了新工作还要学习很多全新的技术栈,并给自己找了很多借口来不去坚持写博客.常常具有讽刺意味的是,更多剩下的时间并没有利用而更多的是白白浪费,也许这就是青春吧,挥霍吧,这不是我想要 ...

  7. emberjs初学记要

    code { margin: 0; padding: 0; white-space: pre; border: none; background: transparent; } code, pre t ...

  8. quora 中有关angular与emberjs的精彩辩论

    原贴地址,要注册才能看,这里只有国人翻译的一部分内容 本文源自于Quora网站的一个问题,作者称最近一直在为一个新的Rails项目寻找一个JavaScript框架,通过筛选,最终纠结于Angular. ...

  9. d3 js emberjs handlerbarjs

    http://handlebarsjs.com/ http://emberjs.com/ http://jsbin.com/d3ember-barchart/13/edit?html,output

随机推荐

  1. HTML5秘籍读书笔记

    1:基本雏形 <html><head> <meta charset="UTF-8"> <title></title>&l ...

  2. TDD in Expert Python Programmin

    Test-Driven Development PrinciplesTDD consists of writing test cases that cover a desired feature, t ...

  3. 2014 Super Training #4 B Problem Arrangement --状压DP

    原题:ZOJ 3777  http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3777 题意:给每个题目安排在每个位置的value ...

  4. spring,hibernate,struts的面试笔试题

    1 Action是不是线程安全的?如果不是 有什么方式可以保证Action的线程安全?如果是,说明原因不是声明局部变量,或者扩展RequestProcessor,让每次都创建一个Action,或者在s ...

  5. C#泛型简化代码量示例

    泛型简化代码量 下是我在项目中通过泛型来简化工作的一个Demo,记录一下: using System; using System.Collections.Generic;   namespace My ...

  6. [3D跑酷] MissionManager

    前言 许久没有更新日志了,之前写了GUIManager,GUIClickEventReceiver还有AudioManager,这次写MissionManager 引用关系 首先看下MissionMa ...

  7. 大话redis/memcache缓存

    通常情况下,随着业务量增加,对后端数据库的访问压力也会随之加大.当数据库访问压力渐渐增大时,除了升级数据库配置提高数据库本身的抗压能力外,我们也可以采用在应用服务器与数据库服务器之间架设数据库缓存服务 ...

  8. Thread锁 Monitor类、Lock关键字和Mutex类

    Monitor 类锁定一个对象 当多线程公用一个对象时,也会出现和公用代码类似的问题,这种问题就不应该使用lock关键字了,这里需要用到System.Threading中的一个类Monitor,我们可 ...

  9. Sublime Text 3 文本编辑器

    1.安装下载 下载地址:http://www.cr173.com/soft/121149.html http://www.xiazaiba.com/html/24343.html 官网 http:// ...

  10. 【原创】有关Silverlight DataGrid双击事件的分析 完整分析 代码与示例

    公司项目用的silverlight,而且silverlight一些技术 资料比较少.所以分享出来 给大家参考参考. 有关Silverlight中DataGrid 双击事件 的代码 如下: 1. 前台x ...