mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-03 21:33:48 +00:00
Added a mock layout and an api call for angular
This commit is contained in:
@@ -1,30 +1 @@
|
||||
function ctrl($scope){
|
||||
$scope.rows = ['Paul','John','Lucie'];
|
||||
$scope.temp = false;
|
||||
|
||||
$scope.addRow = function(){
|
||||
$scope.temp = false;
|
||||
$scope.addName="";
|
||||
};
|
||||
|
||||
$scope.deleteRow = function(row){
|
||||
$scope.rows.splice($scope.rows.indexOf(row),1);
|
||||
};
|
||||
|
||||
$scope.plural = function (tab){
|
||||
return tab.length > 1 ? 's': '';
|
||||
};
|
||||
|
||||
$scope.addTemp = function(){
|
||||
if($scope.temp) $scope.rows.pop();
|
||||
else if($scope.addName) $scope.temp = true;
|
||||
|
||||
if($scope.addName) $scope.rows.push($scope.addName);
|
||||
else $scope.temp = false;
|
||||
};
|
||||
|
||||
$scope.isTemp = function(i){
|
||||
return i==$scope.rows.length-1 && $scope.temp;
|
||||
};
|
||||
|
||||
}
|
||||
var app = angular.module("wrestlingdev", []);
|
||||
17
frontend/app/js/homeController.js
Normal file
17
frontend/app/js/homeController.js
Normal file
@@ -0,0 +1,17 @@
|
||||
app.controller("homeController", function($scope, $http) {
|
||||
$scope.message = "Test message in scope.";
|
||||
|
||||
|
||||
$http({
|
||||
method: 'GET',
|
||||
url: '/api/tournaments/'
|
||||
}).then(function successCallback(response) {
|
||||
// this callback will be called asynchronously
|
||||
// when the response is available
|
||||
$scope.query = response.data;
|
||||
}, function errorCallback(response) {
|
||||
// called asynchronously if an error occurs
|
||||
// or server returns response with an error status.
|
||||
$scope.query = "Nothing there";
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user