Using a corner route in a webapi application

I am not sure how I can implement the correct angular routing in a web API application. I can open pages using this approach: http: // localhost: 52876 / HTML / app / loaner.html

The corner controller boots perfectly and all functions are accessible from the corner.

Now I want to be able to open representations in a more convenient way using ng-route, so for example, http: // localhost: 52876 / HTML / app / loaner.html will become http: // localhost: 52876 / borrower

I have included the ng-route.js file in the HTML files that I use in my corner application.

Also in app.js I have this:

'use strict';

var modules = [
    'app.controllers',
    'LoanAdminApplicationController',
    'ngCookies',
    'ngResource',
    'ngSanitize',
    'ngRoute',
    'ui.router',
    'LocalStorageModule',
    'angular-loading-bar'
];

var app = angular.module('app', modules);


app.config(function ($routeProvider, $locationProvider) {
    $locationProvider.html5Mode(true);
    $routeProvider.when("/home", {
        controller: "homeController",
        templateUrl: "/app/views/home.html"
    });

    $routeProvider.when("/login", {
        controller: "loginController",
        templateUrl: "/HTML/login.html"
    });

    $routeProvider.when("/signup", {
        controller: "signupController",
        templateUrl: "/app/views/signup.html"
    });

    $routeProvider.when("/register", {
        controller: "signupController",
        templateUrl: "/app/views/register.html"
    });

    $routeProvider.when("/refresh", {
        controller: "refreshController",
        templateUrl: "/app/views/refresh.html"
    });

    $routeProvider.when("/tokens", {
        controller: "tokensManagerController",
        templateUrl: "/app/views/tokens.html"
    });

    $routeProvider.when("/borrower", {
        controller: "borrowerController",
        templateUrl: "/HTML/app/borrower.html"
    });

    $routeProvider.otherwise({ redirectTo: "/home" });

});

HTML markup (I deleted the content):

<!DOCTYPE html>
<html ng-app="app">
<head>
</head>
<body ng-controller="BorrowerQuickQuoteApplication">


    <!-- jQuery (necessary for Bootstrap JavaScript plugins) -->
    <script src="/assets/js/jquery.min.js"></script>
    <script src="/assets/js/modernizr.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->

    <script src="/assets/js/bootstrap.min.js"></script>
    <script src="/Scripts/angular.js"></script>
    <script src="/Scripts/angular-cookies.min.js"></script>
    <script src="/Scripts/angular-resource.min.js"></script>
    <script src="/Scripts/angular-sanitize.min.js"></script>
    <script src="/Scripts/angular-route.min.js"></script>
    <script src="/Scripts/angular-ui-router.min.js"></script>
<script src="/Angular/controllers.js"></script>
    <script src="/Angular/LoanApplicationController.js"></script>
    <script src="/Angular/services.js"></script>
    <script src="/Scripts/angular-local-storage.min.js"></script>
<script src="/Scripts/loading-bar.min.js"></script>

<script src="/Angular/app.js"></script>
</body>
</html>

, , ?

RouteConfig.cs - ?

+4
1

, angular, , ,

  $routeProvider.when("/borrower", {
        controller: "borrowerController",
        templateUrl: "/HTML/app/borrower.html"
    });

localhost:8080/yourapp/borrower

ng-view index.html

<div ng-view></div>

.

, , /HTML/app/borrower.html html five mode, , , index.html , url .

+1

Source: https://habr.com/ru/post/1650315/


All Articles