Starting Angular FrontEnd

This commit is contained in:
achrafbenyounes
2014-12-15 18:43:22 +01:00
parent 0a647264d7
commit ffbedc1e02
14 changed files with 109 additions and 16 deletions
+30
View File
@@ -0,0 +1,30 @@
var yltApp = angular.module('YellowLabTools', [
'ngRoute',
'indexCtrl',
'aboutCtrl',
'dashboardCtrl'
]);
yltApp.config(['$routeProvider', '$locationProvider',
function($routeProvider, $locationProvider) {
$routeProvider.
when('/', {
templateUrl: 'front/views/index.html',
controller: 'IndexCtrl'
}).
when('/about', {
templateUrl: 'front/views/about.html',
controller: 'AboutCtrl'
}).
when('/results/:runId', {
templateUrl: 'front/views/dashboard.html',
controller: 'DashboardCtrl'
}).
otherwise({
redirectTo: '/'
});
$locationProvider.html5Mode(true);
}
]);
+5
View File
@@ -0,0 +1,5 @@
var aboutCtrl = angular.module('aboutCtrl', []);
aboutCtrl.controller('AboutCtrl', ['$scope', function($scope) {
$scope.about = "this is about YLT";
}]);
+10
View File
@@ -0,0 +1,10 @@
var dashboardCtrl = angular.module('dashboardCtrl', ['resultsFactory']);
dashboardCtrl.controller('DashboardCtrl', ['$scope', '$routeParams', 'Results', function($scope, $routeParams, Results) {
$scope.dashboard = "this is a dashboard";
$scope.runId = $routeParams.runId;
Results.get({runId: $routeParams.runId}, function(result) {
$scope.result = result;
console.log(result);
});
}]);
+5
View File
@@ -0,0 +1,5 @@
var indexCtrl = angular.module('indexCtrl', []);
indexCtrl.controller('IndexCtrl', ['$scope', function($scope) {
$scope.toto = "Achraf";
}]);
+7
View File
@@ -0,0 +1,7 @@
var resultsFactory = angular.module('resultsFactory', ['ngResource']);
resultsFactory.factory('Results', ['$resource', function($resource) {
return $resource('/api/results/:runId', {
'get': {method: 'GET', params: {runId: '@runId'}}
});
}]);