...and how to make it work with Rails!
- Patrick Aljord / @patcitoHTML is great for declarative code for static web page
<p>Hello world!</p>
Not so for dynamic pages:
<p id="greeting1"></p>
<script>
var isIE = document.attachEvent;
var addListener = isIE
? function(e, t, fn) {
e.attachEvent('on' + t, fn);}
: function(e, t, fn) {
e.addEventListener(t, fn, false);};
addListener(document, 'load', function(){
var greeting = document.getElementById('greeting1');
if (isIE) {
greeting.innerText = 'Hello World!';
} else {
greeting.textContent = 'Hello World!';
}
});
</script>
= Imperative :-(
<p>Hello world</p><p>{{Greeting}}</p>
<script type="text/javascript">
$(function () {
var name = $('#name').val();
var greeting = $('#greeting');
name.keyup(function () {
greeting.text('Hello '+ name + '!');
})
})
</script>
<div>
<label>Name:</label>
<input type="text" id="name">
<p id="greeting"></p>
</div>
<div ng-app>
<label>Name:</label>
<input type="text" ng-model="yourName">
<p>Hello {{yourNameStr}}!</p>
</div>
| Implementation | When? | |
| AngularJS | Javascript | Now |
| Model Driven Views | Native | Future |
| Object.observe | Native | Future |
There's already an AngularJS branch using Object.observe!
↤ Beatiful widgets: Cool
<ul class="nav nav-tabs" id="myTab">
<li class="active"><a href="#section1">Section 1</a></li>
<li><a href="#profile">Section 2</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="section1">Hi, I'm Section 1</div>
<div class="tab-pane" id="section2">Hi, I'm Section 2</div>
</div>
<script>
$(function () {
$('#myTab a:last').tab('show');
})
</script>
<tabs>
<pane title="Section 1">
Hi, I'm Section 1
</pane>
<pane title="Section 2">
Hi, I'm Section 2
</pane>
</tabs>
<google-map>
<tabs>
<tweet>
<avatar>
<color-picker>
<invoice>
| Implementation | When? | |
| AngularJS | DOM+JS (directives) | Now |
| Web Components | Native | Near Future ![]() |
presenting...
$ gem install angularjs_scaffold
$ rails g angularjs:install # adds angular.js and a dummy welcome JS controller
$ rails g scaffold Post title:string body:string
$ rails g angularjs:scaffold Posts # adds everything needed using AngularJS
Enjoy! (still beta!)
https://github.com/patcito/angularjs_scaffold
Credits for the slides: Vojta Jína, Miško Hevery, Igor Minar.