Encountered an error in Angular1: TypeError - promise.catch does not exist as a

Upon using angular-ui-router, I encountered the following error while clicking on the links view1 and view2 in index.html. The same example worked with the regular angular router. Is there something missing in the code? Thanks.

TypeError: promise.catch is not a function
    at silenceUncaughtInPromise (angular-ui-router.js:1079)
    at silentRejection (angular-ui-router.js:1082)
    at angular-ui-router.js:1771
    at handleError (angular-ui-router.js:1614)
    at TransitionHook.invokeHook (angular-ui-router.js:1631)
    at Function.TransitionHook.invokeHooks (angular-ui-router.js:1729)
    at Transition.run (angular-ui-router.js:3475)
    at StateService.transitionTo (angular-ui-router.js:7015)
    at StateService.go (angular-ui-router.js:6911)
    at angular-ui-router.js:8862

app.js -

angular.module('app1',[
'ui.router',
'app.controller']).
config(function($stateProvider,$urlRouterProvider,$locationProvider) {
        $stateProvider.state('view1',{
            url: '/view1',
            controller: 'Controller1',
            templateUrl: '/partials/view1.html'
        }).state('view2',{
            url: '/view2/:firstname/:lastname',
            controller: 'Controller2',
            templateUrl: '/partials/view2.html',
            resolve: {
                names: function(){
                    return ['JavaScript','JQuery','Angular','Bootstrap'];
                }
            }
        });
        $urlRouterProvider.otherwise('/index');
        $locationProvider.html5Mode(true);
});

controller.js -

angular.module('app.controller',[]).
    controller('Controller1',function($scope,$location,$state){
        $scope.loadView2 = function(){      
                $state.go('view2', {
                        firstname: $scope.firstname,
                        lastname: $scope.lastname
                });
            //$location.path('/view2/'+$scope.firstname+'/'+$scope.lastname);
        }
    }).controller('Controller2',function($scope,$stateParams,names){
        $scope.firstname = $stateParams.firstname;
        $scope.lastname = $stateParams.lastname;
        $scope.names = names;
    });

index.html -

<!DOCTYPE html>
<html>
<head>
    <script src="/jquery/jquery.js"></script>
    <script src="/angular/angular.js"></script>
    <script src="/angular/angular-route-1.2.3.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/1.0.3/angular-ui-router.js"></script>
    <script src="/bootstrap/js/bootstrap.js"></script>
    <script src="/js/app.js"></script>
    <script src="/js/controllers.js"></script>
    <link rel="stylesheet" type="text/css" href="/bootstrap/css/bootstrap.css"/>
    <title>
        Angular App
    </title>
</head>
<body ng-app="app1">
    <div>
    <ul class="menu">
<li><a ui-sref="view1">view1</a></li>
<li><a ui-sref="view2">view2</a></li>
</ul>
        <ng-view></ng-view>
    </div>
</body>
</html>

Answer №1

Tip 1
The Angular UI-Router is being used.

To make the necessary changes, in your index.html, swap out <ng-view></ng-view> with <div ui-view></div>

If you were using ngRoute, then ng-view would have been appropriate. But, for your current setup with ui.router, it's best to use <div ui-view></div>

Tip 2
Given that html5Mode is being utilized, ensure you specify the base href within your index.html.
Include <base href="/"> inside the <head> section of your index.html

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

Utilizing the require pattern to integrate JavaScript functionality into HTML

Have: project |- consume_script.js |- index.html Need index.html to be like: <html> <head> </head> <body> <script src="consume_script.js"></script> </body> </html> Issue: consume_script ...

The appearance of random instances of the letter "L" within text on Internet Explorer 8

Help needed! I'm encountering an issue where mysterious "L" characters are appearing in IE 8. The problem is specifically occurring in the Healthcare Professionals section and the bottom two blocks of the page. Has anyone else experienced this or have ...

Retrieving the date input value in AngularJS using ng-model

Attempting to retrieve the value of my HTML 5 input date component by using ng-model binding as shown below: <input type="date" id="dateFin" class="form-control" name="dateFin" ng-model="filtres.dateFin" placeholder="dd/MM/yyyy" min="01 ...

Once the template is fully loaded and rendered, I am looking for an event to trigger

Just dipping my toes into the world of AngularJS and feeling a bit lost. I'm on a mission to discover how to determine when a view has finished rendering its template. I've tried countless suggestions from all over the internet, but nothing seem ...

Navigating to the most recent item within ng-repeat (AngularJS or JavaScript)

I am working on a feature where posts are displayed using ng-repeat in a div, and users can enter new posts in an input box. The posts are sorted so that the latest one appears at the bottom. After adding a new post, I want to automatically scroll down t ...

Adjust the column count based on the screen size, Susy suggested

When using the Compass/Sass plugin Susy, you typically set the number of columns in the _base.scss file. I prefer to have 12 columns for a desktop view, but this may be too many columns for a mobile display. Is there a method to alter the number of column ...

Switching Symbols with JQuery

Hello, I am brand new to utilizing javascript and I'm currently experimenting with the toggle function. My goal is to create show/hide functionality while also toggling arrow icons. Specifically, I want a right arrow next to the link "More -->" and wh ...

What is the best way to connect an image to a different webpage?

I have a question regarding a div that contains an image acting as a link to another page. The image has text overlaying it and can be found at this link: This code was sourced from the internet, but I made some modifications to it. My goal is simply to ...

Aligning two images vertically using the display: table-cell property

I'm trying to align two images vertically using CSS' display: table-cell property, but it doesn't seem to be working even after specifying the height. <div style='display: table;height:500px'> <div style=' displa ...

Switching views in AngularJS by using a controller to control the content displayed in the

My JavaScript web app utilizes AngularJS to simplify tasks, but I've encountered an issue. I'm trying to change views from an ng-controller using $location.path, but for some reason, the view isn't updating even though the path in the $loca ...

Tips on safeguarding your templates while working with SailsJS and AngularJS

I am currently working on a web application using SailsJS and AngularJS. My project requires session management to track user login status. I came across this helpful tutorial and implemented an index.ejs view located in the /view folder. Within the index. ...

Arrange the items in the last row of the flex layout with equal spacing between them

How can I arrange items in rows with equal space between them, without a large gap in the last row? <div fxFlex="row wrap" fxLayoutAlign="space-around"> <my-item *ngFor="let item of items"></my-item> </div> Current Issue: htt ...

Different CSS values can be applied for specific versions of Internet Explorer by using conditional comments

I am dealing with a CSS class named "myclass" that requires a z-index of 5 specifically for IE8. I have attempted to achieve this using the following methods: .myclass{ z-index: 5\9; } ---> Interestingly, this method applies from IE10 onwards and ...

Swap out a button for another using JavaScript

I am facing a challenge where I need to replace an active button with a deactivate button. The issue is that when I click on the active button, it does change to the deactivate button as expected. However, clicking again does not switch it back to the acti ...

When the FileReader reads the file as readAsArrayBuffer, it ensures that the correct encoding is used

Currently, I am developing a script in JavaScript to read uploaded .csv/.xlsx files and convert the data into an array containing each row. Using FileReader along with SheetJs, I have successfully managed to achieve this by implementing the following code: ...

AngularJS Multi-select Dropdown Filter Logic

Thank you for taking the time to review my query. Currently, I am working on an AngularJS UI-Grid project where I have incorporated a Multi-select Drop-down Menu for the "First Name" column. However, I am facing challenges in implementing the logic similar ...

Interact with the horizontal click and drag scroller to navigate through various sections effortlessly, each designed to assist you

Currently, I am facing an issue with my horizontal scrolling feature in JavaScript. It works perfectly for one specific section that has a particular classname, but it fails to replicate the same effects for other sections that share the same classname. ...

Update the Kendo window scrolling feature to include fixed update and cancel buttons

I've encountered an issue while using ASP MVC and the latest version of Kendo. When I add too much content to a Kendo window, it starts scrolling vertically, which ends up hiding the cancel/update buttons at the bottom. This is not ideal as the user s ...

How can the hreflang tag be used correctly in a React application that supports multiple languages?

I have a React application with 3 pages(routes) and I support 2 languages (English and Spanish). Should I insert the following code into the <head></head> section of the public\index.html file like this? <link rel="alternate" ...

Exploring the use of radio buttons with Bootstrap and AngularJS

Having a radio button like this: <tr> <td>GTS ? </td> <td> <div class="col-md-10 columns"> <ul id="GTSD" class="radio" role="menu" aria-labelledby="menu1"> <label class= ...