On Github zabil / angularjsprez
maintained by google
mobile patient care
http://openmrs.org
<html ng-app> <body> .... <script src="angular.js"></script> </body> </html>
var myModule = angular.module("myModule"); myModule.factory('greeter', function(){ return { greet : function(){ return "Hello"; } } });
var services = angular.module("services"); services.factory(...); var controllers = angular.module("controllers"); controllers.controller(...);
var myModule = angular.module("myModule", ['services', 'controllers']);
<html ng-app="myModule"> <body> .... <script src="angular.js"></script> </body> </html>
var myModule = angular.module("myModule"); myModule.factory('greeter', function(){ return { greet : function(){ return "Hello"; } } });
myModule.controller('GreeterController',['Greeter', function(Greeter){ greeter.greet(); }]);
http://awesome.com/index.html#/hello
myModule.config(['$routeProvider', function($routeProvider){ $routeProvider. when('/hello', {templateUrl: 'hello.html'}). when('/bye', {templateUrl:'bye.html'}). otherwise({redirectTo:'/hello'}); }]);
<html ng-app> <body> <div ng-view></div> <script src="angular.js"></script> </body> </html>
myModule.controller('GreeterController',['$scope', function($scope){ } ]);
<div ng-controller="GreeterController"> <input type="text" ng-model="message"></input> </div>
<div ng-controller="GreeterController"> <input type="text" ng-model="message"></input> <div>{{message}}</div> </div>
myModule.controller('GreeterController',['$scope', function($scope){ $scope.greetings = ['Ola', 'Hello', 'Namaste']; } ]);
<div ng-controller="GreeterController"> <ul ng-repeat="greeting in greetings"> <li>{{greeting}}</li> </ul> </div>
myModule.controller('GreeterController',['$scope', function($scope){ $scope.greetings = ['Ola', 'Hello', 'Namaste']; $scope.addGreeting = function(greeting){ $scope.greetings.push(greeting); } } ]);
<div ng-controller="GreeterController"> <input type="text" ng-model="greeting"></input> <input type="button" ng-click="addGreeting(greeting)"></input> <ul ng-repeat="greeting in greetings"> <li>{{greeting}}</li> </ul> </div>
myModule.directive('displayGreeting',function(){ return { templateUrl: 'greeter.html' } });
<div display-greeting>