Can't load a partial view from a file in Angularjs

60 Views Asked by At

I copied a small project from a course and trying to make it run, but apparently something is wrong with the routing or loading the .js files. The controllers and views are in place, i already check that. I get an error when trying to load a view from a file in my pc.

in the index.html this are imports from angularjs

    <head>
        <meta charset="utf-8">
        <title>Welcome to BooKart</title>
        <link rel="stylesheet" href="bootstrap.min.css">
        <link rel="stylesheet" href="css/app.css">
        <script src="angular.min.js"></script>
        <script src="angular-route.js"></script>
         <script src="angular-animate.js"></script>
        <script src="app.js"></script>
    </head>

the routes

myApp.config(function($routeProvider) {
    $routeProvider
        .when("/books", {
            
            templateUrl: "partials/book-list.html",
            controller: "BookListCtrl"
        })
        .when("/kart", {
            templateUrl: "partials/kart-list.html",
            controller: "KartListCtrl"
        })
    .otherwise({
        redirectTo: "/books"
    });
});

in the console i get this error

Could not read source map for file:///C:/Users/***/****/***/angular.min.js: ENOENT: no such file or directory, open 'c:\Users\***/****/***/angular.min.js.map'

in the browser i get this error

index.html#/books:1 Access to XMLHttpRequest at 'file:///C:/Users/***/***/***/partials/book-list.html' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.

Error: [$templateRequest:tpload] http://errors.angularjs.org/1.8.2/$templateRequest/tpload?p0=partials%2Fbook-list.html&p1=-1&p2=
0

There are 0 best solutions below