mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-12 02:42:48 +00:00
got angular routing working - starting on html components
This commit is contained in:
49
public/js/app.js
Normal file
49
public/js/app.js
Normal file
@@ -0,0 +1,49 @@
|
||||
var app = angular.module('app', ['ngRoute']);
|
||||
|
||||
app.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
|
||||
$locationProvider.html5Mode({
|
||||
enabled: true,
|
||||
requireBase: false
|
||||
});
|
||||
|
||||
$routeProvider.
|
||||
when('/', {
|
||||
templateUrl: '/public/view/index.html',
|
||||
controller: 'IndexController'
|
||||
}).
|
||||
when('/sensors', {
|
||||
templateUrl: '/public/view/404.html',
|
||||
controller: 'SensorsController'
|
||||
}).
|
||||
when('/post/:postName', {
|
||||
templateUrl: '/public/view/post.html',
|
||||
controller: 'PostController'
|
||||
}).
|
||||
when('/discord', {
|
||||
redirect: 'https://discordapp.com/invite/0Z2tzxKECEj2BHwj'
|
||||
}).
|
||||
otherwise({
|
||||
templateUrl: '/public/view/404.html'
|
||||
});
|
||||
}]);
|
||||
|
||||
app.controller('IndexController', function($scope) {
|
||||
|
||||
$scope.message = 'This is Add new order screen';
|
||||
|
||||
});
|
||||
|
||||
|
||||
app.controller('SensorsController', function($scope) {
|
||||
|
||||
$scope.message = 'This is Show orders screen';
|
||||
|
||||
});
|
||||
|
||||
|
||||
//handle each post page after individual posts are selected
|
||||
app.controller('PostController', function($scope, $route, $routeParams) {
|
||||
|
||||
$scope.post = "/public/posts/" + $routeParams.postName + ".html";
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user