Last active
April 14, 2016 07:20
-
-
Save diem1/1656289a937b0cf9f1091aa6b7cc7050 to your computer and use it in GitHub Desktop.
Очень быстрый старт с Ember.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://stepansuvorov.com/blog/2014/04/%D0%BE%D1%87%D0%B5%D0%BD%D1%8C-%D0%B1%D1%8B%D1%81%D1%82%D1%80%D1%8B%D0%B9-%D1%81%D1%82%D0%B0%D1%80%D1%82-%D1%81-ember-js/ | |
App = Ember.Application.create({}); | |
App.ApplicationController = Ember.Controller.extend({ | |
message: 'А эту строку выведет в шаблон' | |
}); | |
App.Router.map(function() { | |
this.route("index", { path: "/" }); | |
this.route("list", { path: "/list" }); | |
}); | |
App.IndexController = Ember.Controller.extend({ | |
message: 'Hello! See how index.hbs is evaluated in the context of IndexController' | |
}); | |
App.ListRoute = Ember.Route.extend({ | |
setupController: function(controller) { | |
controller.set('content', ['angular.js', 'backbone.js', 'ember.js']); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type='text/javascript' src='http://code.jquery.com/jquery-1.9.1.js'></script> | |
<script type='text/javascript' src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0-rc.3/handlebars.js"></script> | |
<script type='text/javascript' src="http://cdnjs.cloudflare.com/ajax/libs/ember.js/1.0.0-rc.1/ember.js"></script> | |
<script type="text/javascript" src="app.js"></script> | |
<script type="text/x-handlebars" data-template-name="application"> | |
<div class="container"> | |
<h1>Ember.js быстрое погружение без подготовки</h1> | |
<p>{{message}}</p> | |
<div class="row"> | |
{{#linkTo index class="span3 btn btn-large btn-block"}}Home{{/linkTo}} | |
{{#linkTo list class="span3 btn btn-large btn-block"}}List{{/linkTo}} | |
</div> | |
{{outlet}} | |
</div> | |
</script> | |
<script type="text/x-handlebars" data-template-name="list"> | |
<h3 class="demo-panel-title">Это шаблон списка</h3> | |
<ul> | |
{{#each item in content}} | |
<li>{{item}}</li> | |
{{/each}} | |
</ul> | |
</script> | |
<script type="text/x-handlebars" data-template-name="index"> | |
<h3 class="demo-panel-title">Шаблон главной страницы</h3> | |
<p>{{message}}</p> | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment