server/admin/static/js/app.js

34 lines
875 B
JavaScript

angular.module("FICApp", ["ngRoute", "ngResource"])
.config(function($routeProvider, $locationProvider) {
$routeProvider
.when("/teams", {
controller: "TeamsListController",
templateUrl: "views/team-list.html"
})
.when("/teams/new", {
controller: "TeamNewController",
templateUrl: "views/team-new.html"
});
$locationProvider.html5Mode(true);
})
.run(function($rootScope) {
$rootScope.message = "Hello Angular!";
});
angular.module("FICApp")
.factory("Team", function($resource) {
return $resource("/api/teams/:id", { id: '@id' }, {
'update': { method: "PATCH" }
})
});
angular.module("FICApp")
.controller("TeamsListController", function($scope, Team, $location) {
$scope.teams = Team.query();
$scope.fields = ["id", "name"];
$scope.show = function(id) {
$location.url("/teams/" + id);
};
});