From 13748d3551f5adc231981514edb500d76cff2d66 Mon Sep 17 00:00:00 2001 From: "Vincenzo (Wilk) Ferrari" Date: Fri, 22 Aug 2014 22:23:15 +0200 Subject: [PATCH 1/3] added providers --- app/js/providers.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 app/js/providers.js diff --git a/app/js/providers.js b/app/js/providers.js new file mode 100644 index 0000000000..bd7915da68 --- /dev/null +++ b/app/js/providers.js @@ -0,0 +1,25 @@ +'use strict'; + +/* Providers */ + +angular.module('myApp.providers', []) + .provider('Information', function () { + function Information (about) { + this._about = about; + + this.about = function (about) { + if (about) this._about = about; + + return this._about; + }; + }; + + var aboutInformation = ''; + this.setupInformation = function (about) { + aboutInformation = about; + }; + + this.$get = function () { + return new Information(aboutInformation); + }; + }); \ No newline at end of file From c896f559c75469e231d8e7f94dea8f40ec440777 Mon Sep 17 00:00:00 2001 From: "Vincenzo (Wilk) Ferrari" Date: Fri, 22 Aug 2014 22:23:36 +0200 Subject: [PATCH 2/3] added providers --- app/index.html | 1 + app/js/app.js | 4 +++- app/js/controllers.js | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/index.html b/app/index.html index ae7e943cd9..ccad88c12c 100644 --- a/app/index.html +++ b/app/index.html @@ -35,6 +35,7 @@ + diff --git a/app/js/app.js b/app/js/app.js index d990ec7c9d..45617f9205 100644 --- a/app/js/app.js +++ b/app/js/app.js @@ -6,11 +6,13 @@ angular.module('myApp', [ 'ngRoute', 'myApp.filters', 'myApp.services', + 'myApp.providers', 'myApp.directives', 'myApp.controllers' ]). -config(['$routeProvider', function($routeProvider) { +config(['$routeProvider', 'InformationProvider', function($routeProvider, InformationProvider) { $routeProvider.when('/view1', {templateUrl: 'partials/partial1.html', controller: 'MyCtrl1'}); $routeProvider.when('/view2', {templateUrl: 'partials/partial2.html', controller: 'MyCtrl2'}); $routeProvider.otherwise({redirectTo: '/view1'}); + InformationProvider.setupInformation('Some info to initialize the information class'); }]); diff --git a/app/js/controllers.js b/app/js/controllers.js index 6ec39e1235..76fc708d5b 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -3,8 +3,8 @@ /* Controllers */ angular.module('myApp.controllers', []) - .controller('MyCtrl1', ['$scope', function($scope) { - + .controller('MyCtrl1', ['$scope', 'Information', function($scope, Information) { + console.log(Information.about()); }]) .controller('MyCtrl2', ['$scope', function($scope) { From 22b52b1e929978d3cf3303df3edcfb23d21292a4 Mon Sep 17 00:00:00 2001 From: "Vincenzo (Wilk) Ferrari" Date: Fri, 22 Aug 2014 22:23:45 +0200 Subject: [PATCH 3/3] added providers --- app/index-async.html | 1 + 1 file changed, 1 insertion(+) diff --git a/app/index-async.html b/app/index-async.html index ae63286a5f..3513c3df6a 100644 --- a/app/index-async.html +++ b/app/index-async.html @@ -32,6 +32,7 @@ 'bower_components/angular-route/angular-route.js', 'js/app.js', 'js/services.js', + 'js/providers.js', 'js/controllers.js', 'js/filters.js', 'js/directives.js'