Introduction to Routing
Introduction to Routing
Fundamentals of Routing
Introduction
A single-page application, or SPA, is a website that uses a central webpage that includes a special section to display the contents of other webpages. With SPA, there is no reason for the user to leave one webpage to view the contents of another. The user requests something and the webserver sends the appropriate content to simply update the section that is made to display that particular content. We have already seen that both ASP.NET and AngularJS provide many features for SAPs.
Practical Learning: Introducing Routing
body { background-color: #FFFFFF; } .bold { font-weight: 600; } .blue { color: #0d3bcf; } .maroon { color: #800000; } .top-border { padding-top: 1.05em; border-top: 1px solid #800000; } .topic-title { color: maroon; padding-bottom: 0.25em; border-bottom: 1px solid #800000; } .menu-holder { margin: auto; width: 450px; } .rm-contents { margin: auto; width: 500px; height: 2.80em; background-color: #530505; border: 1px solid black; } .rm-list { list-style: none; } .rm-list li { float: left; } .rm-list li a { padding: 8px; display: block; text-align: center; color: azure; text-decoration: none; border: 1px solid #530505; } .rm-list li a:hover { background-color: #740b0b; border-left: 1px solid maroon; border-right: 1px solid maroon; } .navbar-inverse .navbar-nav > .active > a, .navbar-inverse .navbar-nav > .active > a:hover, .navbar-inverse .navbar-nav > .active > a:focus { color: lightyellow; background-color: #800000; } .navbar-fixed-top { background-color: #530505; } .common-font { font-family: Georgia, Garamond, 'Times New Roman' , serif; }
using System.Web.Mvc;
namespace SunriseResidence1.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult About()
{
ViewBag.Message = "We offer comfort. We advocate convenience. And we support our tenants.";
return View();
}
public ActionResult Contact()
{
ViewBag.Message = "Please contact us today for all your rental concerns.";
return View();
}
public ActionResult RentManagement() => View();
}
}
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>@ViewBag.Title - Sunrise Residence</title> @Styles.Render("~/Content/css") @Scripts.Render("~/bundles/modernizr") </head> <body> <div class="navbar navbar-inverse navbar-fixed-top"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> @Html.ActionLink("Sunrise Residence", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" }) </div> <div class="navbar-collapse collapse"> <ul class="nav navbar-nav"> <li>@Html.ActionLink("Rent Management", "RentManagement", "Home")</li> <li>@Html.ActionLink("About", "About", "Home")</li> <li>@Html.ActionLink("Contact", "Contact", "Home")</li> </ul> </div> </div> </div> <div class="container body-content"> @RenderBody() </div> <footer class="top-border container common-font"> <p class="text-center">© @DateTime.Now.Year - Sunrise Residence</p> </footer> @Scripts.Render("~/bundles/jquery") @Scripts.Render("~/bundles/bootstrap") @RenderSection("scripts", required: false) </body> </html>
Introduction to Routing in AngularJS
One way AngularJS implements SPAs is by using custom directives and components. One more feature available in AngularJS consists of indicating to the webserver what Web content to display in a reserved section of a central webpage. This is referred to as routing. As always, you have many options. To support routing, AngularJS provides a special module named ngRoute. Before using it, there are a few steps you must follow.
A Library for Routing
You must first have the right library. You can download and install it. To do this in Microsoft Visual Studio, after starting a project, in the Solution Explorer, right-click the name of the project and click Manage NuGet Packages... In the NuGet: tab, click Browse and type angularjs (you will need to be connected to the Internet because Microsoft Visual Studio will have to download the library). In the list of options that come up, click AngularJS.Route. Click Install. If a Preview message box comes up, read it and click OK. This will install both angular-route.js and angular-route.min.js files, among others. Alternatively, you can visit the AngularJS website, download, and install the route library.
In your project or the document where you are writing your code, in addition to the AngularJS file that we have used so far, you must add a reference to the angular-route.js (and/or the angular-route.min.js) file(s).
Practical Learning: Introducing the Routing Library
@{ ViewBag.Title = "Rent Management"; } @Scripts.Render("~/bundles/jquery") <h2 class="text-center blue common-font bold">Apartments Rental Management</h2>
var appSunrise = angular.module('SunriseResidence', []);
A Dependent Module
When creating an AngularJS module in your code, you must indicate that your module depends on the ngRoute module. As you may know already, to indicate that a module depends on another, add the depending module in the array that is the second argument to the module() function. It is passed as a string (in single or double-quotes). Here is an example:
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Country's Summary</title> <script src="../Scripts/angular.js"></script> <script src="angular-route.js"></script> </head> <body ng-app="webPageRouting"> <script type="text/javascript"> angular.module('webPageRouting', ['ngRoute']); </script> </body> </html>
Then you are ready to perform routing operations in AngularJS.
Practical Learning: Introducing the AngularJS Router
var appSunrise = angular.module('SunriseResidence', ['ngRoute']);
A Route Provider
To support routing, AngularJS is equipped with a service named $routeProvider. To use this service, since it is a provider, we saw that you should (must) pass it as an argument to the function passed to config(). This can be done as follows:
var app = angular.module('webPageRouting', ['ngRoute']);
app.config(function ($routeProvider) {
});
Of course if necessary, you can pass additional arguments, such as additional services, to the function.
Practical Learning: Introducing a Route Provider
var appSunrise = angular.module('SunriseResidence', ['ngRoute']);
appSunrise.config(function ($routeProvider) {
});
using System.Web; using System.Web.Optimization; namespace SunriseResidence1 { public class BundleConfig { // For more information on bundling, visit https://go.microsoft.com/fwlink/?LinkId=301862 public static void RegisterBundles(BundleCollection bundles) { bundles.Add(new ScriptBundle("~/bundles/jquery").Include( "~/Scripts/jquery-{version}.js", "~/Scripts/angular.js", "~/Scripts/angular-route.js", "~/Scripts/RentManagement.js")); bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include( "~/Scripts/jquery.validate*")); // Use the development version of Modernizr to develop with and learn from. Then, when you're // ready for production, use the build tool at https://modernizr.com to pick only the tests you need. bundles.Add(new ScriptBundle("~/bundles/modernizr").Include( "~/Scripts/modernizr-*")); bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include( "~/Scripts/bootstrap.js", "~/Scripts/respond.js")); bundles.Add(new StyleBundle("~/Content/css").Include( "~/Content/bootstrap.css", "~/Content/site.css", "~/Content/SunriseResidence.css")); } } }
Primary Characteristics of AngularJS Routing
Introduction to the Links of a Routing System
To implement routing, you can first create the link(s) that will indicate the document(s) to be accessed. The primary formula to create a link is:
<a href="#!link-name">link-string</a>
Create the link using the same symbols and words as in HTML. Instead of an address, use #! followed by a name you will programmatically use to refer to the link (later). Here is an example:
<a href="#!Vehicles">. . .</a>
Between the start and end tags, provide the text that will display to the visitor. Here is an example:
<a href="#!Vehicles">Vehicles</a>
In the same way, you can create as many links as you want. You can create them in a list, a table, etc.
Practical Learning: Introducing Routing Links
@{ ViewBag.Title = "Rent Management"; } @Scripts.Render("~/bundles/jquery") <div ng-app="SunriseResidence"> <h2 class="text-center blue common-font bold">Apartments Rental Management</h2> <div class="rm-contents"> <ul class="rm-list menu-holder"> <li><a href="#!Apartments">Apartments</a></li> <li><a href="#!RentContracts">Rent Contracts</a></li> <li><a href="#!Payments">Payments</a></li> <li><a href="#!Employees">Employees</a></li> </ul> </div> </div>
A Directive Section
As you may know already (from ASP.NET MVC), in AngularJS, you must specify the section where the contents of the other pages would display. This is done by adding a directive named ng-view from the ngView object. You can create it as an element. Here is an example:
. . .
<script src="../Scripts/angular.js"></script>
<script src="../Scripts/angular-route.js"></script>
</head>
<body ng-app="webPageRouting">
. . .
<ng-view></ng-view>
<script type="text/javascript">
var app = angular.module('webPageRouting', ['ngRoute']);
app.config(function ($routeProvider) {
});
</script>
</body>
</html>
You can also create it an attribute to an HTML element. Here is an example:
<div ng-view></div>
Or you can specify it as a CSS class. Here is an example:
<div class="ng-view"></div>
Practical Learning: Introducing the Directive View
@{
ViewBag.Title = "Rent Management";
}
@Scripts.Render("~/bundles/jquery")
<div ng-app="SunriseResidence">
<h2 class="text-center blue common-font bold">Apartments Rental Management</h2>
<div class="rm-contents">
<ul class="rm-list menu-holder">
<li><a href="#!Apartments">Apartments</a></li>
<li><a href="#!RentContracts">Rent Contracts</a></li>
<li><a href="#!Payments">Payments</a></li>
<li><a href="#!Employees">Employees</a></li>
</ul>
</div>
<div class="top-border">
<ng-view></ng-view>
</div>
</div>
When a Name is Accessed
To use the $routeProvider provider, you must create a navigation scheme as a list of options to control this service. As a result, the $routeProvider service works like a switch statement of most computer languages. When it comes to the $routeProvider service, each case is dealt with by a method named when. The syntax of this method is:
when(path, route);
You must attach each call of this function to a $routeProvider object. Therefore, the formula to use this service is:
$routeProvider.when(path1, route1).when(path2, route2)...when(path_n, route_n);
The $routeProvider.when() method takes two arguments. The first argument is the name you would have created for a link in the view. That name is passed as a string. It should be preceded by a a forward slash '/'. Here is an example:
. . . <script src="../Scripts/angular.js"></script> <script src="../Scripts/angular-route.js"></script> </head> <body ng-app="webPageRouting"> <h1>:: Country's Review ::</h1> <p><a href="#!History">Historical Events</a></p> <ng-view></ng-view> <script type="text/javascript"> var app = angular.module('webPageRouting', ['ngRoute']); app.config(function ($routeProvider) { $routeProvider.when('/History', . . .) }); </script> </body> </html>
A Template for a Link
The second argument is an object that specifies what to display when a link is clicked:
var app = angular.module('webPageRouting', ['ngRoute']);
app.config(function ($routeProvider) {
$routeProvider.when('/History', {})
});
You have many options. As seen with custom directives and Components, to create the content to display, add a template property to the object and set its value as the desired text. The value can contain simple text, HTML code, and CSS format. Here are two examples:
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Country's Review</title> <script src="../Scripts/angular.js"></script> <script src="../Scripts/angular-route.js"></script> </head> <body ng-app="webPageRouting"> <h1>:: Country's Review ::</h1> <ul> <li><a href="#!History">Historical Events</a></li> <li><a href="#!Geography">Geographical Studies</a></li> </ul> <hr color="red" /> <ng-view></ng-view> <script type="text/javascript"> var app = angular.module('webPageRouting', ['ngRoute']); app.config(function ($routeProvider) { $routeProvider .when('/History', { template: '<h1>History</h1><p>The first part of this document provides a short review of the history of this country.</p>' }) .when('/Geography', { template: '<h1>Geography</h1><p>Here is a review of moutains, valleys, rivers, and national parks of the country.</p>' }) }); </script> </body> </html>
Practical Learning: Introducing Link Templates
var appSunrise = angular.module('SunriseResidence', ['ngRoute']);
appSunrise.config(function ($routeProvider) {
$routeProvider.
when('/Apartments', {
template: "<h3 class='text-center common-font blue bold'>Apartments</h2>" +
"<p class='common-font'>This is a list of the apartments on rent by this company.</p>"
}).
when('/RentContracts', {
template: "<h3 class='text-center common-font blue bold'>Rent Contracts</h2>" +
"<p class='common-font'>Here are the details of the rent contracts of the current residents.</p>"
}).
when('/Payments', {
template: "<h3 class='text-center common-font blue bold'>Payments</h2>" +
"<p class='common-font'>This section shows the rent payments made by the tenants.</p>"
}).
when('/Employees', {
template: "<h3 class='text-center common-font blue bold'>Employees</h2>" +
"<p class='common-font'>Meet our staff members, including employees, contractors, technicians, associates, etc.</p>"
});
});
Options on Configuring Routing
The Route Home
To specify the default page, start its address as #/! followed by the string you want the user so see, such as Home or something like that. Pass the first argument of the when() argument as a forward slash. Set the value of the template property anyway you want.
Practical Learning: Adding the Ooute Home
@{
ViewBag.Title = "Rent Management";
}
@Scripts.Render("~/bundles/jquery")
<div ng-app="SunriseResidence">
<h2 class="text-center blue common-font bold">Apartments Rental Management</h2>
<div class="rm-contents">
<ul class="rm-list menu-holder">
<li><a href="#/!Home">Home</a></li>
<li><a href="#!Apartments">Apartments</a></li>
<li><a href="#!RentContracts">Rent Contracts</a></li>
<li><a href="#!Payments">Payments</a></li>
<li><a href="#!Employees">Employees</a></li>
</ul>
</div>
<div class="top-border">
<ng-view></ng-view>
</div>
</div>
var appSunrise = angular.module('SunriseResidence', ['ngRoute']);
appSunrise.config(function ($routeProvider) {
$routeProvider.
when('/', {
template: "<h3 class='text-center common-font maroon bold'>Welcome</h2>" +
"<p class='common-font'>Here is introductory information you should have about our residence.</p>"
}).
when('/Apartments', {
template: "<h3 class='text-center common-font blue bold'>Apartments</h2>" +
"<p class='common-font'>This is a list of the apartments on rent by this company.</p>"
}).
when('/RentContracts', {
template: "<h3 class='text-center common-font blue bold'>Rent Contracts</h2>" +
"<p class='common-font'>Here are the details of the rent contracts of the current residents.</p>"
}).
when('/Payments', {
template: "<h3 class='text-center common-font blue bold'>Payments</h2>" +
"<p class='common-font'>This section shows the rent payments made by the tenants.</p>"
}).
when('/Employees', {
template: "<h3 class='text-center common-font blue bold'>Employees</h2>" +
"<p class='common-font'>Meet our staff members, including employees, contractors, technicians, associates, etc.</p>"
});
});
. . . No Change
.menu-holder { margin: auto;
width: 500px; }
. . . No Change
If a Route Definition is Not Found
After specifying the target links of a $routeProvider service, when the user clicks a link, if there is no corresponding document, nothing will happen. This may create confusion to the visitor. To let you provide a default content, the $routeProvider object is equipped with a method named otherwise. If the $routeProvider service and its when() method is equivalent to the switch statement of the computer languages, its otherwise() method corresponds to the default clause.
The $routeProvider.otherwise() method takes one argument that can be a string or an object. If you pass it as an object, you can add a template property to it and set its value as the default text to display. Here is an example:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Country's Review</title>
<script src="../Scripts/angular.js"></script>
<script src="../Scripts/angular-route.js"></script>
</head>
<body ng-app="webPageRouting">
<h1>:: Country's Review ::</h1>
<ul>
<li><a href="#!History">Historical Events</a></li>
<li><a href="#!Geography">Geographical Studies</a></li>
<li><a href="#!Website">Web Site</a></li>
</ul>
<hr color="red" />
<ng-view></ng-view>
<script type="text/javascript">
var app = angular.module('webPageRouting', ['ngRoute']);
app.config(function ($routeProvider) {
$routeProvider.
when('/History', {
template: '<h1>History</h1><p>The first part of this document provides a short review of the history of this country.</p>'
}).
when('/Geography', {
template: '<h1>Geography</h1><p>Here is a review of moutains, valleys, rivers, and national parks of the country.</p>'
}).
otherwise({
template: '<p>Sorry for the inconvenience, the content is under development...</p>'
})
});
</script>
</body>
</html>
Practical Learning: Providing an All Alternate Route
var appSunrise = angular.module('SunriseResidence', ['ngRoute']);
appSunrise.config(function ($routeProvider) {
$routeProvider.
when('/', {
template: "<h2 class='text-center common-font maroon bold'>Welcome</h2>" +
"<p class='common-font'>Here is introductory information you should have about our residence.</p>"
}).
when('/Apartments', {
template: "<h3 class='text-center common-font blue bold'>Apartments</h2>" +
"<p class='common-font'>This is a list of the apartments on rent by this company.</p>"
}).
when('/RentContracts', {
template: "<h3 class='text-center common-font blue bold'>Rent Contracts</h2>" +
"<p class='common-font'>Here are the details of the rent contracts of the current residents.</p>"
}).
when('/Payments', {
template: "<h3 class='text-center common-font blue bold'>Payments</h2>" +
"<p class='common-font'>This section shows the rent payments made by the tenants.</p>"
}).
when('/Employees', {
template: "<h3 class='text-center common-font blue bold'>Employees</h2>" +
"<p class='common-font'>Meet our staff members, including employees, contractors, technicians, associates, etc.</p>"
}).
otherwise({
template: "<p>This section is under construction...</p>"
});
});
@{
ViewBag.Title = "Rent Management";
}
@Scripts.Render("~/bundles/jquery")
<div ng-app="SunriseResidence">
<h2 class="text-center blue common-font bold">Apartments Rental Management</h2>
<div class="rm-contents">
<ul class="rm-list menu-holder">
<li><a href="#/!Home">Home</a></li>
<li><a href="#!Apartments">Apartments</a></li>
<li><a href="#!RentContracts">Rent Contracts</a></li>
<li><a href="#!Payments">Payments</a></li>
<li><a href="#!Employees">Employees</a></li>
<li><a href="#!Security">Security/Maintenance</a></li>
</ul>
</div>
<div class="top-border">
<ng-view></ng-view>
</div>
</div>
. . . No Change .menu-holder { margin: auto; width: 650px; } .rm-contents { margin: auto; width: 600px; height: 2.80em; background-color: #530505; border: 1px solid black; } . . . No Change
@{ ViewBag.Title = "Rent Management"; } @Scripts.Render("~/bundles/jquery") <div ng-app="SunriseResidence"> <h2 class="text-center blue common-font bold">Apartments Rental Management</h2> <div class="rm-contents"> <ul class="rm-list menu-holder"> <li><a href="#/!Home">Home</a></li> <li><a href="#!Apartments">Apartments</a></li> <li><a href="#!RentContracts">Rent Contracts</a></li> <li><a href="#!Payments">Payments</a></li> <li><a href="#!Employees">Employees</a></li> </ul> </div> <div class="top-border"> <ng-view></ng-view> </div> </div>
. . . No Change .menu-holder { margin: auto; width: 500px; } .rm-contents { margin: auto; width: 550px; height: 2.80em; background-color: #530505; border: 1px solid black; } . . . No Change
Controlling the Contents of a Route
As seen with directives, you can use a controller to create the content that will display when a routing link is clicked. In the body of the function of the controller, create one or more properties attached to a this object or to a $scope service. In the object of the when() method, add a controller property and set its value as the name of the controller you had created. If you had attached the properties of the controller using the this object, create an instance of the controller. Still in the when() object, add a template property. In its value, create the necessary {{}} placeholders and fill each with the desired properties from the controller. Here is an example:
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Country's Review</title> <script src="../Scripts/angular.js"></script> <script src="../Scripts/angular-route.js"></script> </head> <body ng-app="webPageRouting"> <h1>:: Country's Review ::</h1> <ul> <li><a href="#!History">Historical Events</a></li> <li><a href="#!Geography">Geographical Studies</a></li> </ul> <hr color="red" /> <ng-view></ng-view> <script type="text/javascript"> var app = angular.module('webPageRouting', ['ngRoute']); app.controller('HistoryController', [function () { this.title = 'Historical Events'; this.content = 'The first part of this document provides a short review of the history of this country.' }]); app.config(function ($routeProvider) { $routeProvider. when('/History', { controller: 'HistoryController as hc', template: '<h1>{{hc.title}}</h1><p>{{hc.content}}</p> ' }). when('/Geography', { template: '<h1>Geography</h1><p>Here is a review of moutains, valleys, rivers, and national parks of the country.</p>' }) }); </script> </body> </html>
Practical Learning: Controlling the Contents of a Route
var appSunrise = angular.module('SunriseResidence', ['ngRoute']); appSunrise.controller('RentManagementController', ['$scope', function ($scope) { $scope.apartmentsTitle = "Apartments"; $scope.apartmentsDescriptions = "This is the general apartments listing of our community."; $scope.contractsTitle = "Rent Contracts"; $scope.contractsDetails = "This is an overview of the various contracts of our multiple tenants."; $scope.paymentsTitle = "Rent Payments"; $scope.paymentsDetails = "We use this section to track the rent payments of the residents."; $scope.employeesTitle = "Employees"; $scope.employeesInformation = "This section contains a list of our staff members: employees, technicians/contractors, interns, etc."; }]); appSunrise.config(function ($routeProvider) { $routeProvider. when('/', { template: "<h2 class='text-center common-font maroon bold'>Welcome</h2>" + "<p class='common-font'>Here is introductory information you should have about our residence.</p>" }). when('/Apartments', { controller: "RentManagementController", template: "<h3 class='text-center common-font blue bold'>{{apartmentsTitle}}</h2>" + "<p class='common-font'>{{apartmentsDescriptions}}</p>" }). when('/RentContracts', { controller: "RentManagementController", template: "<h3 class='text-center common-font blue bold'>{{contractsTitle}}</h2>" + "<p class='common-font'>{{contractsDetails}}</p>" }). when('/Payments', { controller: "RentManagementController", template: "<h3 class='text-center common-font blue bold'>{{paymentsTitle}}</h2>" + "<p class='common-font'>{{paymentsDetails}}</p>" }). when('/Employees', { controller: "RentManagementController", template: "<h3 class='text-center common-font blue bold'>{{employeesTitle}}</h2>" + "<p class='common-font'>{{employeesInformation}}</p>" }). otherwise({ template: "<p>This section is under construction...</p>" }); });
var appSunrise = angular.module('SunriseResidence', ['ngRoute']); appSunrise.controller('ApartmentsController', ['$scope', function ($scope) { $scope.apartmentsTitle = "Apartments"; $scope.apartmentsDescriptions = "This is the general apartments listing of our community."; }]).controller('RentContractsController', ['$scope', function ($scope) { $scope.contractsTitle = "Rent Contracts"; $scope.contractsDetails = "This is an overview of the various contracts of our multiple tenants."; }]).controller('PaymentsController', ['$scope', function ($scope) { $scope.paymentsTitle = "Rent Payments"; $scope.paymentsDetails = "We use this section to track the rent payments of the residents."; }]).controller('EmployeesController', ['$scope', function ($scope) { $scope.employeesTitle = "Employees"; $scope.employeesInformation = "This section contains a list of our staff members: employees, technicians/contractors, interns, etc."; }]); appSunrise.config(function ($routeProvider) { $routeProvider. when('/', { template: "<h2 class='text-center common-font maroon bold'>Welcome</h2>" + "<p class='common-font'>Here is introductory information you should have about our residence.</p>" }). when('/Apartments', { controller: "ApartmentsController", template: "<h3 class='text-center common-font blue bold'>{{apartmentsTitle}}</h2>" + "<p class='common-font'>{{apartmentsDescriptions}}</p>" }). when('/RentContracts', { controller: "RentContractsController", template: "<h3 class='text-center common-font blue bold'>{{contractsTitle}}</h2>" + "<p class='common-font'>{{contractsDetails}}</p>" }). when('/Payments', { controller: "PaymentsController", template: "<h3 class='text-center common-font blue bold'>{{paymentsTitle}}</h2>" + "<p class='common-font'>{{paymentsDetails}}</p>" }). when('/Employees', { controller: "EmployeesController", template: "<h3 class='text-center common-font blue bold'>{{employeesTitle}}</h2>" + "<p class='common-font'>{{employeesInformation}}</p>" }). otherwise({ template: "<p>This section is under construction...</p>" }); });
appSunrise.controller('ApartmentsController', ['$scope', function ($scope) { $scope.apartmentsTitle = "Apartments"; $scope.apartmentsDescriptions = "This is the general apartments listing of our community."; }]);
appSunrise.controller('RentContractsController', ['$scope', function ($scope) { $scope.contractsTitle = "Rent Contracts"; $scope.contractsDetails = "This is an overview of the various contracts of our multiple tenants."; }]);
appSunrise.controller('PaymentsController', ['$scope', function ($scope) { $scope.paymentsTitle = "Rent Payments"; $scope.paymentsDetails = "We use this section to track the rent payments of the residents."; }]);
appSunrise.controller('EmployeesController', ['$scope', function ($scope) { $scope.employeesTitle = "Employees"; $scope.employeesInformation = "This section contains a list of our staff members: employees, technicians/contractors, interns, etc."; }]);
var appSunrise = angular.module('SunriseResidence', ['ngRoute']); appSunrise.config(function ($routeProvider) { $routeProvider. when('/', { template: "<h2 class='text-center common-font maroon bold'>Welcome</h2>" + "<p class='common-font'>Here is introductory information you should have about our residence.</p>" }). when('/Apartments', { controller: "ApartmentsController", template: "<h3 class='text-center common-font blue bold'>{{apartmentsTitle}}</h2>" + "<p class='common-font'>{{apartmentsDescriptions}}</p>" }). when('/RentContracts', { controller: "RentContractsController", template: "<h3 class='text-center common-font blue bold'>{{contractsTitle}}</h2>" + "<p class='common-font'>{{contractsDetails}}</p>" }). when('/Payments', { controller: "PaymentsController", template: "<h3 class='text-center common-font blue bold'>{{paymentsTitle}}</h2>" + "<p class='common-font'>{{paymentsDetails}}</p>" }). when('/Employees', { controller: "EmployeesController", template: "<h3 class='text-center common-font blue bold'>{{employeesTitle}}</h2>" + "<p class='common-font'>{{employeesInformation}}</p>" }). otherwise({ template: "<p>This section is under construction...</p>" }); });
using System.Web.Optimization;
namespace ApartmentsRentalCompany1
{
public class BundleConfig
{
// For more information on bundling, visit https://go.microsoft.com/fwlink/?LinkId=301862
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js",
"~/Scripts/angular.js",
"~/Scripts/angular-route.js",
"~/Scripts/RentManagement.js",
"~/Scripts/PaymentsController.js",
"~/Scripts/EmployeesController.js",
"~/Scripts/ApartmentsController.js",
"~/Scripts/RentContractsController.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.validate*"));
// Use the development version of Modernizr to develop with and learn from. Then, when you're
// ready for production, use the build tool at https://modernizr.com to pick only the tests you need.
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/modernizr-*"));
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.js",
"~/Scripts/respond.js"));
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/site.css",
"~/Content/SunriseResidence.css"));
}
}
}
|
||
Previous | Copyright © 2018-2022, FunctionX | Next |
|