angularJS 1.6 is not compatible with this route

I am currently working with angularjs 1.6 to develop a basic application that lists groups and their respective users, but I am facing an issue in displaying the list of users using ng-view.

This is how my index.html looks like:

<!DOCTYPE html>
<html lang="en" ng-app="application"> 
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>My application</title>
  <meta name="description" content="">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" type="text/css" href="assets/bootstrap-3/css/bootstrap.min.css">
  <link rel="stylesheet" href="assets/app.css">
</head>
<body>
  <div ng-controller="groupctrl">
    <div class="well">
      <ul ng-repeat="grp in group">
        <li class="link" ng-click="displayusers(grp.uuid)">{{ grp.name }}</li>
        <li class="link" ng-click="displayusers(grp.uuid)">{{ grp.name }}</li>
     </ul>
    </div>
  </div>
    <div ng-view>

    </div>
</body>
  <script src="assets/angular.min.js"></script>
  <script src="assets/angular-route.min.js"></script>
  <script src="controllers/app.js"></script>
  <script src="controllers/route.js"></script>
  <script src="controllers/service.js"></script>
  <script src="controllers/mainctrl.js"></script>

</html>

app.js

var app = angular.module('application', ['ngRoute']);

route.js and mainctrl.js

app.config(['$locationProvider', '$routeProvider', 
function($locationProvider, $routeProvider) {

  $locationProvider.hashPrefix('!');

  $routeProvider
  .when('/', {
    templateUrl: 'index.html'
   })
  // .when('/group', {
  //   templateUrl: 'group.html',
  //   controller: 'groupctrl'
  //  })
   .when('/users', {
    templateUrl: 'users.html',
    controller: 'usersctrl'
   })
  .otherwise({redirectTo: '/'});
}]);

app
.controller('groupctrl', function($scope, $timeout, $location, apiService) {

$scope.hello = "hello 123";

apiService.getgroup().then(function(data){
$scope.group = data;
});

$scope.displayusers = function(idgroup){
apiService.getusers(idgroup);
$location.path('/users');
};

})
.controller('usersctrl', function($scope, $timeout, apiService) {


apiService.getusers().then(function(data){
$scope.users = data;
});

});

users.html

<div ng-controller="usersctrl">
    <div ng-repeat="user in users">
      <div class="well text-center">
         <h2>{{ user.name }}</h2>
         <h5>{{ user.index }}</h5>
             <button class="btn btn-success" ng-click="edit(user.index)">EDIT</button>
             <button class="btn btn-danger" ng-click="delete(user.index)">DELETE</button>
      </div>
    </div>
  </div> 

Thank you for any assistance!

Answer №1

The issue lies in the author's comments regarding the inability to access the users.html file due to an error message:

XMLHttpRequest cannot load file:///home/folder-test/Documents/application/users.html. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https

Solutions to this problem can be found in similar discussions on Stack Overflow such as this one and more specifically addressing AngularJS at this link.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Having difficulty retrieving items from Mongoose-Node database

I am currently working with a Mongodb database that stores resume objects. These objects contain various skills information and I have set up a node-express server to query the database based on specific skills. For example, when querying for a skill like ...

Appending a new element to a JSON object using JavaScript

Hey there, I have a JSON object called departments. When I use console.log(departments) it displays the following data: { _id: 58089a9c86337d1894ae1834, departmentName: 'Software Engineering', clientId: '57ff553e94542e1c2fd41d26', ...

Angular facing problems with tracking comment counts in Disqus

After successfully setting up the Disqus comments system on my Angular website following the guide at , everything was working fine. However, when attempting to add the Disqus comment count system to my homepage using the code provided at , I encountered a ...

Tips for updating a div element while maintaining its style and select2 plugin functionality with jQuery

Within the HTML code, I am attempting to refresh the following div: <select name="test[]" id="test" multiple required class="select2"> @foreach($tests as $s) ...

The angularjs ngrepeat directive seems to be experiencing difficulties when working with an object in the angular wizard

Hello all, I am a newcomer to angularjs and currently using version 1.5.8 (unable to upgrade at the moment). My issue lies with trying to implement ng-repeat alongside angular wizard, following the example provided here. However, when it comes to repeating ...

Guide on shifting an element into a different one with the help of jQuery

I'm attempting to relocate an element within another in order to enable a css :hover effect. <ul> <li id="menu-item"> //move into here </li> </ul> <div class="tomove">...</div> 'tomove' is set to dis ...

Opacity of the color obtained from the props in a styled component

I attempted to adjust the opacity of a color passed as props. I achieved this using Sass like so: background: rgba($primary, 0.2); However, when trying to accomplish the same with styled-components, it doesn't seem to work. `background-color: rgba(${ ...

Vue.js component unable to validate HTML input patterns

Attempting to create HTML forms with the 'pattern' input attribute has been an interesting challenge for me. When implementing this through Vue.js components, I encountered some strange behavior. Check out this fiddle to see it in action. Vue.co ...

Using jQuery Grep to refine a JSON nested array

My goal is to extract the first level array from JSON data based on specific criteria in the second level of the array. I am utilizing jQuery grep to pinpoint elements within an array and filter them based on department and job title. In my scenario, I am ...

What sets Joomla file inclusion apart from the rest?

Can someone please explain the difference between including a JavaScript script file in the following two ways? I created this within a system plugin in Joomla and included the JavaScript file inside the "onAfterInitialise" function. 1) <script type ...

Highlighting PHP files as JavaScript files in Sublime Text for improved readability

I'm working with a group of .php files in Sublime Text that primarily consist of JavaScript code with some PHP constants mixed in. Is there a way to configure Sublime Text to consistently highlight these files as JavaScript instead of PHP without havi ...

The onLoad event of the <picture /> element is not consistently being triggered

I'm encountering an issue where the onLoad event on the picture element is not consistently firing. I have tried adding the onload event listener to both the picture and image elements, but sometimes they both fire and other times neither of them do. ...

"Facing an issue with angular's $http post method as it fails to transmit

Attempting to use $http post in Angular to send an object to a REST service. The data is a JSON object that needs to be passed as a parameter for the method in the service. Here is my Angular code (which is not working for me): $http({ method:'P ...

Exploring the world of Restify: Mastering the art of sending POST

Having trouble reading the body of a request while trying to create an API with Restify. Snippet from main.js: 'use strict'; const perfy = require('perfy'); perfy.start('startup'); const restify = require('rest ...

Searching for specific data within a dataset using lodash's wildcard functionality

My array structure resembles the one below, and I am attempting to execute a wildcard search to retrieve the associated value. Unfortunately, the current method is not yielding any results. Can anyone suggest an alternative approach for achieving this? I a ...

Adjusting the width of the search bar in a Bootstrap inline form

Issue: The search box is not resizing with the page and I can't figure out how to make it wider. Adding styles like width: 100%; hasn't worked so far. In addition, the select dropdown box in the image linked below appears slightly clipped on the ...

Connect Bootstrap Tabs to a pagination system (Backward Forward)

<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://m ...

Error encountered during execution of Angular application, specifically TS2305 error?

Hello, I am currently running an angular application by using the 'ng serve' command. I encountered the following error: ERROR in src/app/accounts/account-form/account-form.component.ts(29,3): error TS2305: Module '"/home/prasanth/primecas ...

Issue duplicating DIV elements using jQuery's clone() method causes button duplication error

Just starting out with programming, so my code might not be perfect. I'm encountering an issue when I click a button in the HTML (Fiddle) $(document).ready(function() { $("button").click(function() { $(".groupcontainer").clone().appendTo(".grou ...

Tips for identifying when a gif has completed a single playback using JavaScript

Is it possible to detect when a gif reaches its loop point using Javascript in order to mimic the preloaders used for flash content? I currently have a script that checks when a video has loaded, but I'm looking for a way to do this same check when a ...