Advertisement
Guest User

Untitled

a guest
Apr 17th, 2014
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. var app = angular.module('app', []);
  2.  
  3. app.controller('UserController', function ($scope, UserService) {
  4. // Define the model properties. The view will loop
  5. // through the services array and genreate a li
  6. // element for every one of its items.
  7.  
  8. $scope.services = [
  9. {
  10. name: 'Web Development',
  11. price: 300,
  12. active: true
  13. }, {
  14. name: 'Design',
  15. price: 400,
  16. active: false
  17. }, {
  18. name: 'Integration',
  19. price: 250,
  20. active: false
  21. }, {
  22. name: 'Training',
  23. price: 220,
  24. active: false
  25. }
  26. ];
  27.  
  28. $scope.LogInfo = {
  29. UserName: 'username',
  30. Password: 'password'
  31. };
  32.  
  33. $scope.ProcessLogin = function (Info) {
  34. UserService.GetLoginStatus(Info);
  35. };
  36.  
  37. $scope.toggleActive = function (s) {
  38. s.active = !s.active;
  39. };
  40.  
  41. // Helper method for calculating the total price
  42.  
  43. $scope.total = function () {
  44.  
  45. var total = 0;
  46.  
  47. // Use the angular forEach helper method to
  48. // loop through the services array:
  49.  
  50. angular.forEach($scope.services, function (s) {
  51. if (s.active) {
  52. total += s.price;
  53. }
  54. });
  55.  
  56. return total;
  57. };
  58. });
  59.  
  60. app.service('UserService', function () {
  61. this.GetLoginStatus = function (Info) {
  62. alert(JSON.stringify(Info))
  63. };
  64. });
  65.  
  66. app.controller('UserController', function ($scope, UserService) {
  67. &
  68. app.service('UserService', function () {
  69.  
  70. angular.module('app').controller('UserController', function ($scope, UserService) {
  71. &
  72. angular.module('app').service('UserService', function () {
  73.  
  74. <body ng-controller="UserController" ng-app="app">
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement