-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
67 lines (51 loc) · 1.54 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// create the module and name it scotchApp
var scotchApp = angular.module('scotchApp', ['ngRoute']);
// configure our routes
scotchApp.config(function($routeProvider) {
$routeProvider
// route for the home page
.when('/', {
templateUrl : 'pages/home.html',
controller : 'mainController'
})
// route for the about page
.when('/about', {
templateUrl : 'pages/about.html',
controller : 'mainController'
})
// route for the contact page
.when('/contact', {
templateUrl : 'pages/contact.html',
controller : 'contactController'
});
});
// create the controller and inject Angular's $scope
scotchApp.service('formService',function(){
var formData = [];
this.setValues = function(a,b){
formData.push(a);
formData.push(b);
// return formData;
console.log(formData);
}
this.getValues = function(){return formData }
});
scotchApp.controller('mainController', function($scope,$location,formService) {
// var a = ;
// var b = $scope.last;
// console.log(a);
$scope.saveValues = function(){
formService.setValues($scope.first,$scope.last);
$location.path('/about');
}
$scope.secondValues = function(a,b){
formService.setValues($scope.t1,$scope.t2);
$location.path('/contact');
}
// $scope.message = 'Contact us! JK. This is just a demo.';
});
scotchApp.controller('contactController', function($scope,formService) {
// create a message to display in our view
$scope.values = formService.getValues();
// alert($scope.values);
});