Angular+JQ+Bootstrap
HTML
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="http://code.angularjs.org/1.0.0/angular-1.0.0.js"></script>
<div ng-controller="Ctrl1">
<h1>Ctrl1</h1>
<input type="text" placeholder="new item text" ng-model="newItemText" />
<br />
<button ng-click="addItem(newItemText); newItemText='';" ng-show="newItemText.length" class="btn btn-primary">Add {{newItemText}}</button>
</div>
<hr />
<div ng-controller="Ctrl2">
<h1>Ctrl2</h1>
<ul>
<li ng-repeat="item in items">{{item}}</li>
</ul>
</div>
JavaScript
var app=angular.module('myApp', []);
function Ctrl1($scope, itemManager) {
$scope.addItem = function(text) {
itemManager.items.push(text);
alert(itemManager.test(text));
};
}
function Ctrl2($scope, itemManager) {
$scope.items = itemManager.items;
}
app.factory('itemManager', function() {
return {
items: []
test:function(testo){
return testo + " ciao";
}
};
});