How can we redirect to another page from existing page on clicking alert

0 votes
I want to have a page where if i click on one link,then alert message will pop up and on clicking on that pop up i will redirect to other page?
Feb 6, 2020 in Angular by kartik
• 37,490 points
1,396 views

1 answer to this question.

0 votes

hii,

It is really simple to redirect from existing to other specified page on clicking on alert.

The sample code to acquire this scenario is:

var app= angular.module( 'app', [ngRoute]);
app.config([ '$routeProvider', function($routeProvider){
        $routeProvider.when( '/first-msg' ,{
        templateURl :msg.htm,
        controller:message1

        .when( '/second-msg' ,{
         redirectTo: function(){                                 

            alert("SORRY!!! You will be redirect to first message");

            return:"/first-msg"
})
}]);

         Hope this sample piece of code can work for you!! 

answered Feb 6, 2020 by Niroj
• 82,580 points

Related Questions In Angular

0 votes
1 answer

How can we reload a page after requesting the same get parameter using AngularJS?

hey kartik, The reason for this is that ...READ MORE

answered Feb 10, 2020 in Angular by Niroj
• 82,580 points
7,261 views
0 votes
1 answer

How can we provide condition based on certain resolve result obtained in routing with resolve?

Hey,  Let me consider that you have some ...READ MORE

answered Feb 11, 2020 in Angular by Niroj
• 82,580 points
131 views
0 votes
1 answer

How can we achieve transclusion in AngularJs?

Hii,  In order to know what transclusion is ...READ MORE

answered Feb 5, 2020 in Angular by Niroj
• 82,580 points
97 views
0 votes
1 answer

How can we achieve transclusion using link function and directive controller?

Hey, The Term Transclusion means unhidding the context ...READ MORE

answered Feb 5, 2020 in Angular by Niroj
• 82,580 points
213 views
0 votes
1 answer
0 votes
0 answers

Anyone can help me out to understand the semantic of (document.getElementBYId("demo").innerHTML="Hello") ?

Hello guys, Can Someone helps me to find ...READ MORE

Jan 17, 2020 in Web Development by anonymous
• 37,490 points
154 views
+1 vote
1 answer

What is the relationship between angularjs Scope with controller/view?

Let us consider the below block: <div ng-controller="emp"> ...READ MORE

answered Jan 20, 2020 in Web Development by Niroj
• 82,580 points

edited Jan 21, 2020 by Niroj 205 views
+1 vote
1 answer

What are pseudo class in css??

Hey, The state of an element is controlled  by ...READ MORE

answered Jan 20, 2020 in Web Development by Niroj
• 82,580 points

edited Jan 21, 2020 by Niroj 116 views
0 votes
1 answer

How can we redirect to an existing route using ngRoute?

Routing is just another way of fixing some content ...READ MORE

answered Feb 6, 2020 in Angular by Niroj
• 82,580 points
612 views
0 votes
1 answer

How can we go back to previous page after having some error on request made through current page ?

$route is used for deep-linking URLs to controllers ...READ MORE

answered Feb 11, 2020 in Angular by Niroj
• 82,580 points
119 views