AngularJS Live Example
by Alex
HTML
<div ng:app="myApp">
<div ng-controller="Ctrl1">
Hello <input ng-model='name' ng-model-instant> <hr/>
<span ng:bind="name"></span> <br/>
<span>{{result}}</span>
</div>
</div>
CSS
.ng-invalid { border: 1px solid red; }
body { font-family: Arial,Helvetica,sans-serif; }
body, td, th { font-size: 14px; margin: 0; }
table { border-collapse: separate; border-spacing: 2px; display: table; margin-bottom: 0; margin-top: 0; -moz-box-sizing: border-box; text-indent: 0; }
a:link, a:visited, a:hover { color: #5D6DB6; text-decoration: none; }
.error { color: red; }
JavaScript
var myApp = angular.module('myApp', [])
.factory('myService', ['$q', '$http', function($q,$http) {
return function(scope) {
//var d = $q.defer();
var h = $http({method: 'GET', url: 'http://fiddle.jshell.net/echo/json/'})
.success(function(data, status, headers, config){
});
return h
}}
]);
function Ctrl1($scope, myService) {
$scope.name = 'angular';
$scope.result = myService($scope);
}