Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var app = angular.module('app', []);
- app.controller('UserController', function ($scope, UserService) {
- // Define the model properties. The view will loop
- // through the services array and genreate a li
- // element for every one of its items.
- $scope.services = [
- {
- name: 'Web Development',
- price: 300,
- active: true
- }, {
- name: 'Design',
- price: 400,
- active: false
- }, {
- name: 'Integration',
- price: 250,
- active: false
- }, {
- name: 'Training',
- price: 220,
- active: false
- }
- ];
- $scope.LogInfo = {
- UserName: 'username',
- Password: 'password'
- };
- $scope.ProcessLogin = function (Info) {
- UserService.GetLoginStatus(Info);
- };
- $scope.toggleActive = function (s) {
- s.active = !s.active;
- };
- // Helper method for calculating the total price
- $scope.total = function () {
- var total = 0;
- // Use the angular forEach helper method to
- // loop through the services array:
- angular.forEach($scope.services, function (s) {
- if (s.active) {
- total += s.price;
- }
- });
- return total;
- };
- });
- app.service('UserService', function () {
- this.GetLoginStatus = function (Info) {
- alert(JSON.stringify(Info))
- };
- });
- app.controller('UserController', function ($scope, UserService) {
- &
- app.service('UserService', function () {
- angular.module('app').controller('UserController', function ($scope, UserService) {
- &
- angular.module('app').service('UserService', function () {
- <body ng-controller="UserController" ng-app="app">
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement