In ractive there is nothing equivalent to this; module.controller('FooController', function($scope, userService){ $scope.data = userService.api.success(function(data) .etc.. ); });
You do not have to bind a controller to a scope. You can still do this: <input type="text" value="{{yourName}}" placeholder="Enter a name here"> <h1>Hello {{yourName}}!</h1> Notice no ng-modal, simply {{yourName}}. On Thursday, 19 June 2014 19:07:30 UTC-5, samuel bonill wrote: > > Massimo, in angularjs, if you want use Promises in all the application > scope, you need Factory o services, example : > > var module = angular.module('myapp', []); > > module.service('userService', function(){ > this.api = $http.get('http://example.com/blog/default/index/blog.json > '); > }); > > // controller #1 > module.controller('FooController', function($scope, userService){ > $scope.data = userService.api.success(function(data) .etc.. ); > > }); > > // controller #2 > module.controller('BarController', function($scope, userService){ > $scope.my_scope = userService.api.success(function(data) .etc.. ); > }); > > > link: http://viralpatel.net/blogs/angularjs-service-factory-tutorial/ > > > and data binding it's very easy... example : > > <input type="text" ng-model="yourName" placeholder="Enter a name here"> > > <h1>Hello {{yourName}}!</h1> > > > https://angularjs.org/ > > for learn more : > http://campus.codeschool.com/courses/shaping-up-with-angular-js/ > > > > 2014-06-19 17:41 GMT-05:00 Massimo Di Pierro <massimo.dipie...@gmail.com>: > >> In this thread there are lots of references to various libraries but they >> are not all the same and serve different purposes. >> >> I like sugar.js and ractive.js >> >> sugar.js is similar to underscore.js+moments.js and it extends basic >> objects like Date, Array, and String so that they have more methods. >> >> ractive.js is a reactive template language. That means you do not decide >> when to render the template (as in typical jQuery templates or web2py >> templates) but when data changes (clientside data in js), the page is >> automatically updated. This is an example >> http://learn.ractivejs.org/two-way-binding/1/ [click on "fix code" to >> see it working. >> >> ractive has lots of overlap with angular but angular constraints you a >> lot because of the concept of scope and requires that you follow lots of >> conventions. For example angular Promises leave inside the scope and the >> scope to a controller which, in their jargon, is a piece of a web page. >> What if you need Promises in function defined outside the scope because >> they are shared across controllers? Moreover the complexity of the syntax >> for defining controller grows in complexity as soon as you try do something >> non-trivial. I find ractive to be more intuitive. I am tempted to say >> Angular is to Django as Ractive is to web2py. >> >> Massimo >> >> -- >> Resources: >> - http://web2py.com >> - http://web2py.com/book (Documentation) >> - http://github.com/web2py/web2py (Source code) >> - https://code.google.com/p/web2py/issues/list (Report Issues) >> --- >> You received this message because you are subscribed to a topic in the >> Google Groups "web2py-users" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/web2py/LCXnVnIeLl4/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> web2py+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. >> > > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.