<!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. TYVJ1288 飘飘乎居士取能量块 -SilverN

    描述   9月21日,今天是pink的生日,飘飘乎居士当然要去别人的领土大闹一番啦!  为了收集更多的能量到pink家大闹,飘飘乎居士准备从后花园中取出自己多年积攒的p个能量块.后花园一共被划分n个地 ...

  2. runc create container 流程分析

    1.// runc/create.go Action: func(context *cli.Context) error 首先调用spec, err := setupSpec(context)加载配置 ...

  3. 如何用dos命令运行testng

    写好的自动化程序怎么让它运行呢,总不能每次都启动eclipse吧,下面就先介绍一种用dos命令运行testNG的方法. 1.把项目打成jar吧,我用的是Fat jar工具. 2.在电脑的某个盘建一个文 ...

  4. 【读书笔记《Android游戏编程之从零开始》】12.游戏开发基础(Canvas 画布)

    1.Canvas 画布 画布类 Canvas 封装了图形和图片绘制等内容,此类常用的函数说明如下: drawColor(int color) 作用:绘制颜色覆盖画布,常用于刷屏 参数:颜色值,也可用十 ...

  5. 内网穿透利器 Ngrok 使用教程

    ngrok 服务可以分配给你一个域名让你本地的web项目提供给外网访问,特别适合向别人展示你本机的web demo 以及调试一些远程的API (比如微信公众号,企业号的开发) 下面开始教程 Step ...

  6. fontAwesome代替网页icon小图标

    引言 奥森图标(Font Awesome)提供丰富的矢量字体图标—通过CSS可以任意控制所有图标的大小 ,颜色,阴影. 网页小图标到处可见,如果一个网页都是干巴巴的文字和图片,而没有小图标,会显得非常 ...

  7. 第25章 SEH结构化异常处理_未处理异常及向量化异常

    25.1 UnhandledExceptionFilter函数详解 25.1.1 BaseProcessStart伪代码(Kernel32内部) void BaseProcessStart(PVOID ...

  8. java 21 - 12 随机访问流(不属于IO流)

    随机访问流: RandomAccessFile类不属于流,是Object类的子类. 但它融合了InputStream和OutputStream的功能. 支持对文件的随机访问读取和写入. public ...

  9. Python 栅栏凯撒

    def fence_Crypto(msg,priority="row"): ''' usage: fence_Crypto(msg[, priority])->msg to ...

  10. js模拟手机触摸屏

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...