`The Abode and an Inventory Sheet`

I am trying to transition from my home application to a list. Both the list and my home are in different .js files. How can I display my home first, and then with one click, navigate to the list?

First, here is the code and view for the home:

home-component.js

(function(){
     'use strict';
    var home = {
        templateUrl: './app/components/list-component/home-component/home.html',
        controller: homeCtrl
    };

    angular
    .module('payApp')
    .component('home', home);

    function homeCtrl(){

        var home = this;
    }  

    })();

home.html

<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-body">
                <div class="row">
                    <div class="col-lg-7">
                        <div class="title">
                            <h3><strong>¡Welcome!</strong></h3>
                        </div>
                        <br>
                        <div class="col-md-6 .col-md-offset-3">
                            <button class="btn btn-success" ng-click="">Start</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

Now, here are my list files.

payment-component.js

(function(){
     'use strict';
    var pays = {
        templateUrl: './app/components/list-component/paymentcompo.html',
        controller: payCtrl
    };

    angular
    .module('payApp')
    .component('payInvoice', pays);
    payCtrl.$inject = ["$scope"];
    function payCtrl($scope){

}
})();

HTML view for payment:

paymentcompo.html

<table class="table table-hover">
        <thead>
            <tr>
                <th>Payment Number</th>
                <th>Name</th>
                <th>Tax Id</th>
            </tr>
        </thead>
        <tbody>
            <tr id="pool" ng-repeat="info in list | filter: search">
                <th>{{info.Id}}</th>
                <th>{{info.name}}</th>
                <th>{{info.taxId}}</th>
            </tr>
        </tbody>
    </table>

Lastly, here is my index.html:

<!DOCTYPE html>
<html lang="en" ng-app="payApp">

    <meta charset="UTF-8">
    <title>Pay This</title>
    <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <link type="text/css" href="app/componentes/css/pay-style.css" rel="stylesheet" />
    <link type="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.7.1/css/bootstrap-datepicker3.standalone.min.css" rel="stylesheet"/>

<head>


</head>

<body>

<pay-Invoice></pay-Invoice>


<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<script src="bootstrap/js/bootstrap-popover.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.7.1/js/bootstrap-datepicker.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.7.1/js/bootstrap-datepicker.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.5/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.5/angular-resource.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.5/angular-route.min.js"></script>
<script src="app/payapp.js"></script>
<script src="app/components/list-component/payment-component.js"></script>
<script src="app/components/list-component/home-component/home-component.js"></script>
<script src="app/factory/pay-factories.js"></script>
<script src="app/routes/routes.js">

</body>
</html>

I have added ngRoute as recommended and created the routes.js.

EDITED

This is my routes.js:

(function(){
    'use strict';

    angular
        .module('payApp')
        .config(config);


    config.$inject = ["$routeProvider","$locationProvider"];
        function config($routeProvider, $locationProvider){

            $routeProvider
                .when('/home',{
                    template: '<home></home>',
                })

                .when('/listado',{
                    template: '<pay-invoice></pay-invoice>',
                })

                .otherwise({
                    redirectTo: '/home',
                });

                $locationProvider.html5Mode(true);

        }

        })();

To make this work, I need to display the home view first and then navigate to the list view when the button on the home view is clicked. Any suggestions on how to achieve this seamlessly? Thank you for your assistance.

Answer №1

If you are utilizing angular-route, it is necessary to establish a container div in your main HTML file.

Instead of:

<pay-Invoice></pay-Invoice>

in your index HTML file, insert a container component:

<div ng-view></div>

This will instruct ngRoute to mount route components to this container and switch it when the location changes. Find out more here: https://docs.angularjs.org/api/ngRoute/directive/ngView

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

Generate an image on Canvas using a URL link

I have a unique URL that generates canvas images with specific parameters. It functions properly when loaded in a browser. The final line of code is: window.location = canvas.toDataURL("image/png"); However, when attempting to use this URL from another ...

How to display 3 items per row in a React table by utilizing a map function loop

Currently, my table using material UI generates one column on each row. However, I would like to display 3 columns as items on each row. Below is the mapping for my table: <TableBody> {this.props.data.slice(page * rowsPerPage, page * rowsPerPage ...

AJAX using PHP returns an object containing null values

As a beginner in ajax programming, I encountered a small issue. I created a function in jQuery that makes an ajax call to a PHP file, which then retrieves information about a player from the database. However, when the PHP file responds to the ajax functio ...

The behavior of Angular 4 CSS and JS changes upon refreshing the page

Every time I try to load a page with this particular script: this.router.navigateByUrl('/report-result/'+report.id); It appears that not all the CSS and JS files are being loaded properly. The bootstrap popovers don't show up, and some ele ...

Why does xpath insist on choosing spaces instead of actual elements?

Here is a list of countries in XML format: <countries> <country> <code>CA</code> <name>Canada</name> </country> ... etc... </countries> I am looking to extract and loop through these nodes, so ...

Exploring the power of ES6 map function within React stateless components

I have a React application that fetches an array of objects from an API response. I want to display each object's details in an accordion format. Using the react-accessible accordion library, I created a React Stateless Component to achieve this. Each ...

What is the best way to have DOMDocument processed in PHP after running Javascript?

Currently, I'm working on a program that searches for tags. Unfortunately, I'm encountering difficulties retrieving tags created with JavaScript. ...

Having trouble getting anime.js to function properly in an Ionic 3 project?

I have been attempting to incorporate anime.js into my Ionic 3 project, but I keep encountering an error when using the function anime({}) in the .ts file. Error: Uncaught (in promise): TypeError: __webpack_require__.i(...) is not a function TypeError: _ ...

Issue with toggling functionality in Vue.js between two identical components

Within the template of another component, I have two components that can be toggled based on clicks on "reply" and "edit" buttons. <comment-form :model="model" :model-id="modelId" :comment="comment" v-if="showEditForm && canComment" @closeForm= ...

Angular9: construction involves an additional compilation process

After updating my Angular8 project to Angular9, I noticed a new step in the build process which involves compiling to esm. This additional step has added approximately 1 minute to my build time. A snippet of what this step looks like: Compiling @angular/ ...

Prevent Form Submission in Microsoft Edge

I need help figuring out how to prevent Microsoft Edge from keeping form values, such as inputs, when a page refreshes. You can see the issue by looking at the first name last name example on this page https://www.tutorialspoint.com/html/html_forms.htm. ...

AngularJS field array

Is it possible to create an array that contains references to the fields in a form (such as input, textarea, etc.) and then run a function on them in my code, like addClass()? To clarify my objective - I am looking to add a red border color to any invalid ...

Having trouble running a form due to the inclusion of JavaScript within PHP code

My PHP code includes a form that connects to a database, but when I add JavaScript to the same file, the form does not execute properly. (I have omitted the insert code here.) echo '<form action="$_SERVER["REQUEST_URI"];" method="POST">'; ...

Combining outcomes from two separate jQuery AJAX requests and implementing deferred/promise functionality

I am struggling to combine the outcomes of two jQuery AJAX requests. Despite reviewing similar questions here, none seem to provide a solution. Each ajax call (2 in total) has a success function that calls the createStatusView function and passes it the ...

Adding elements to a roster

Can anyone assist me with appending data from a csv file to an unordered HTML list? The csv file I have contains both single and grouped data for the list, as seen below: Test Group Name A,Test Link Name 1,Test URL 1 Test Group Name A,Test Link Name 2,Tes ...

I'm struggling to figure out why my code is throwing an Unexpected token error. What am I missing here?

I keep encountering an Unexpected token error in my code, specifically with a closing parenthesis ). What exactly does this error signify? Experimented by adding and removing parentheses as well as curly brackets. const getUserChoice = userInput => {u ...

Utilizing JavaScript AJAX to upload a dynamically generated PDF file to a specific directory on the server

Looking for a solution to save a complex table generated via JavaScript as a PDF on the server. Existing pdf generation libraries have limitations with style and fonts, making it difficult for 'complex' tables. The table can currently be download ...

JavaScript: Incorporating an operator into a specific object (instead of the entire class)

Are you familiar with how to include an operator in an object (rather than the entire class)? When it comes to a method, I know you can achieve that by: my_object.new_function = function(){return 1}; Then invoking my_object.new_function() will output ...

What's causing the failure in the execution of the "Verify version" step?

Upon reviewing the 3DSecure GlobalPay documentation, my team decided to integrate it using JSON, incorporating our own client-side implementation. This decision was made because we already have another integration with a different 3DS verification service ...

A dynamic input field will appear on the page following the closing </form> tag

I encountered an unusual situation where upon clicking a button with the id #fusk, dynamic elements are added. Here is the code snippet: $('#imgc').append( "<div class='divi'>" + "<input type='hidden' name=' ...