Is it possible to navigate to the Next page using a different button instead of the pagination controls

Is it possible to navigate to the next page upon clicking a button labeled "Press me"? Here is the code snippet:

<!doctype html>
<html ng-app="plunker">
  <head>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js"></script>
    <script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.3.0.js"></script>
    <script src="example.js"></script>
    <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">
  </head>
  <body>

<div ng-controller="PaginationDemoCtrl">

    <pagination num-pages="noOfPages" current-page="currentPage" max-size="maxSize"></pagination>
    The selected page number is: {{currentPage}}
</div>

<button>Press me</button>

  </body>
</html>

http://plnkr.co/edit/NVgCX8nrx0ovnCWE2eok?p=preview

Answer №1

... It seems like your question is a bit unclear, but I think this might be the solution you're seeking:

<button value='Click here' onClick='window.location.href="./abc123xyz?p=view"'>

Answer №2

To implement functionality in your HTML, move your controller to the body tag and create a click event for a button.

<!doctype html>
<html ng-app="plunker">
    <head>
        <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js"></script>
        <script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.3.0.js"></script>
        <script src="example.js"></script>
        <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">
    </head>
    <body ng-controller="PaginationDemoCtrl">
        <div>
            <pagination num-pages="noOfPages" current-page="currentPage" max-size="maxSize"></pagination>
            The selected page no: {{currentPage}}
        </div>
        <button ng-click="goToNext()">Press me</button>
    </body>
</html>

In your script, include a function to manage the click event, which simply increments the current page number.

angular.module('plunker', ['ui.bootstrap']);
var PaginationDemoCtrl = function($scope) {
  $scope.noOfPages = 20;
  $scope.currentPage = 4;
  $scope.maxSize = 5;

  $scope.setPage = function(pageNo) {
    $scope.currentPage = pageNo;
  };

  $scope.goToNext = function() {
    $scope.currentPage = ++$scope.currentPage;
  };
};

Answer №3

Check out this Plunk sample

  1. Relocate
    ng-controller="PaginationDemoCtrl"
    to the body tag.
  2. Add a directive to the button that says ng-click="setPage(currentPage+1)

<!doctype html>
<html ng-app="plunker">
  <head>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js"></script>
    <script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.3.0.js"></script>
    <script src="example.js"></script>
    <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">
  </head>
  <body ng-controller="PaginationDemoCtrl">

    <div>
      <pagination num-pages="noOfPages" current-page="currentPage" max-size="maxSize"></pagination>
      The current selected page is: {{currentPage}}
    </div>

    <button ng-click="setPage(currentPage+1)">Click me</button>
  </body>
</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

Using a combination of ASP.NET webpage and JavaScript, a dynamic webpage with a repe

I am new to using VB and integrating JavaScript. I have a simple question, but I'm having trouble figuring it out for some reason. I am struggling to properly construct an IF-statement. Can you please help me? I have searched and googled, but have no ...

Choosing Tags with Ajax in Select2

The JSON data below is fetched from /tags: [ { "id": "CSS", "text": "CSS" }, { "id": "HTML", "text": "HTML" }, { "id": "JavaScript", "text": "JavaScript" }, { "id": "jQuer ...

Merging HTML Array with jQuery

I am working with input fields of type text in the following code snippet: <input type="text" minlength="1" maxlength="1" class="myinputs" name="myinputs[]" > <input type="text" minlength="1" maxlength="1" class="myinputs" name="myinputs[]" > ...

Issue Detected at a Precise Line Number - Android Studio

Despite my numerous attempts to modify the specific line in question, including leaving it empty, turning it into a comment, or removing it entirely, the error message persists. I even went as far as deleting the class and creating a new one, but the same ...

Exploring the boundaries of React's useContext functionality

In my applications, I specialize in creating custom hooks for accessing state stores. For example, I typically define the hook like this: const store = new Store(); const StoreContext = createContext(store); StoreContext.displayName = "StoreContext"; fun ...

Encountering a "MissingSchemaError" while attempting to populate the database with mongoose-seeder

I am facing an issue while trying to populate a database using mongoose-seeder. Despite setting up the schema correctly, I keep encountering a MissingSchemaError which has left me puzzled. Here is a snippet from the file where I define the schema: const m ...

Is it possible for AngularJS components to alter their enclosing element?

I see Angular components as element directives. Take a component named hero, for example, I can include it in the parent template like so: <hero myparam="something"></hero> What I envision is using the hero element as a container managed by t ...

Implementing AJAX notifications in a contact form integrated with PHP, Google reCAPTCHA, and SweetAlert

I've implemented an AJAX script to handle the submission of a basic contact form with Google reCAPTCHA at the end of my HTML. Here's the relevant HTML code: <div class="col-md-6"> <form role="form" id="form" action="form.php" method ...

At what point does the promise's then function transition to being either fulfilled or rejected?

When dealing with promises in JavaScript, the then() method returns a promise that can be in one of three states: pending, fulfilled, or rejected. You can create a promise using the resolved and rejected methods to indicate when it should be fulfilled or r ...

loading xml data into a table partially using jquery

Currently, I am utilizing AJAX to load and parse XML data. I have constructed a table where I am inserting the data from the XML using a loop. The issue lies in the fact that only around 3000 rows are being inserted into the table even though the XML conta ...

From time to time, the web application encounters the error message net::ERR_NAME_NOT_RESOL

Currently, I am working on developing a simple web app card game. The concept is straightforward- users log in and begin playing by selecting three matching cards then hitting submit. When the submit button is clicked, the chosen cards' names are sent ...

What is the best way to preload all videos on my website and across different pages?

I specialize in creating video websites using HTML5 with the <video> tag. On my personal computer, the website transitions (fadeIn and fadeOut) smoothly. However, on my server, each page seems to take too long to load because the videos start preloa ...

How to retrieve JSON data in Angular.js

I'm having trouble accessing a json file in angular.js with the code below. I keep getting an error message and could really use some help! Here is my module : angular.module("demoApp", ['demoApp.factory','demoApp.controllers']); ...

Dropdown for state selection within WooCommerce for specific countries

I am encountering a challenge in configuring a form with default WooCommerce country and states selection dropdowns. Essentially, my goal is to present the Country selection first, followed by the State selection based on the chosen country. For instance, ...

Restricting input in Angular using negative regular expressions - a new approach to input restriction directive

UPDATE: Please feel free to include additional validations that may be helpful for others within this straightforward directive. -- I am currently in the process of creating an Angular Directive that restricts the characters inputted into a text box. Whi ...

Mobile Chrome allows users to utilize the IFrame player API for enhanced video

Currently, I am working on creating a mobile website where I plan to include some YouTube videos using the IFrame player API (https://developers.google.com/youtube/iframe_api_reference). My main goal is to have the video start playing only after the user ...

Using Angular 8, remember to not only create a model but also to properly set it

hello Here is a sample of the model I am working with: export interface SiteSetting { postSetting: PostSetting; } export interface PostSetting { showDataRecordAfterSomeDay: number; } I am trying to populate this model in a component and set it ...

Discovering the bottom side of a cube using Euler Angles (or Quaternions) in three.js

Hey there! I have a little puzzle that I could use your help with: Imagine this - I've got a cube that can be rotated around three different axes. I've gathered some data on the cube's rotation, specifically an array of three angles rangi ...

Utilize React to generate HTML content and send it as the email body through Node.js

I am currently working on a react application that consists of two main pages - AddStatus and ViewStatus. Both of these are implemented as react components. My current task involves sending out an email daily at a specific time, containing the details dis ...

The requested URL socket.io/1/?t= cannot be located

I've created a web application running on rails 4 at localhost:3000. A client-side angularjs is also incorporated into the project. The socket.io.js file has been placed in the public folder of my rails app. In my angularjs client code, I have the fol ...