Moving from one section to the next within a web page

I am looking to add animation to my web app. When clicked, I want to move only the ID table column from one div to another div while hiding the other column. However, I am struggling with figuring out how to animate the movement of the ID column (from the green div) to the red div. Here is the JSFIDDLE link for reference: https://jsfiddle.net/q4eotzb0/6/

<body>
<script type="text/javascript">
var app = angular.module('MyApp', [])
app.controller('MyController', function($scope) {
  //This will hide the DIV by default.
  $scope.IsVisible = true;
  $scope.ShowHide = function() {
    //If DIV is visible it will be hidden and vice versa.
    $scope.IsVisible = !$scope.IsVisible;
  }
});

<br />
<br />
<div class="meni col-lg-2 col-md-2 col-sm-12 col-xs-12">
 <ul>
  <li>home</li>
  <li>home</li>
  <li>home</li>
  <li>home</li>
  <li>home</li>
 </ul>
</div >
<div class="container-fluid col-lg-10 col-md-10 col-sm-12 col-xs-12">

<div class="test col-lg-4 col-md-4 col-sm-12 col-xs-12" ng-class="{'divOpen': IsVisible}">
 <div ng-if="!IsVisible">
    ID<br>
    50<br>
    51<br>
    52<br>
 </div>
 <div ng-if="IsVisible">
  MAPs
 </div>
</div>
<div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
 <div class="testtest">
 <input type="button" ng-if="!IsVisible" value="Back" ng-click="ShowHide()" />
   <table class="table" ng-if="IsVisible">
    <tr>
    <td>ID</td>
    <td>NAME</td>
    <td>LOCATION</td>
    <td>No</td>
    </tr>
    <tr>
    <td>50</td>
    <td>NAME</td>
    <td>LOCATION</td>
    <td> <input type="button" value="SHOW/HIDE" ng-click="ShowHide()" /></td>
    </tr>
    <tr>
    <td>51</td>
    <td>NAME</td>
    <td>LOCATION</td>
    <td> <input type="button" value="SHOW/HIDE" ng-click="ShowHide()" /></td>
    </tr>
    <tr>
    <td>52</td>
    <td>NAME</td>
    <td>LOCATION</td>
   INFO item
   </table>
 </div>
</div>
</div>

.test {
background: red;
width: 50px;
height: 350px;
-webkit-transition: width 2s;-moz-transition: width 2s ease-in-out;-ms-
transition: width 2s ease-in-out;
-o-transition: width 2s ease-in-out;transition: width 2s;
}


.divOpen{
 width: 100px;
 }
.testtest{
 background: green;
 height: 350px;
 width: auto;
 }
.meni {
 background-color: grey;
 height: 350px;
 }

Answer №1

The Angular router is perfect for this task! By setting a new templateUrl for each route, you can easily change it with just a click or event.

Make sure to include an additional script (https://ajax.googleapis.com/ajax/libs/angularjs/1.6.6/angular-route.min.js). To see how the router works, check out this example:

https://www.w3schools.com/angular/angular_routing.asp.

JSFIDDLE provides a good explanation of ngRoute.

Lastly, remember to add a CSS transition to the incoming HTML object:

<script type="text/ng-template" id="embedded.home.html">
    <h1 class="fade-in"> Home </h1>
</script>

<script type="text/ng-template" id="embedded.about.html">
    <h1 class="fade-in"> About </h1>
</script>

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 a JSON file using Node.js

I've been honing my skills with Node.js and express by working on a project involving a JavaScript object that generates a dropdown list. The process has been smooth so far. Recently, I integrated mongoose to create a model and saved it. Now, in my co ...

How can multiple arguments be passed to a function using JQuery's post method?

I can't seem to figure out how to pass multiple arguments to a function using jQuery's post method. It might sound like a silly question, but I'm struggling with it. Currently, my code looks something like this: $.post("<?php echo site_ ...

Schema-specific conditions for JSON data

I have been experimenting with the if-then-else statement in JSON, but I am encountering some issues with it. { "type": "object", "minProperties": 2, "maxProperties": 2, "properties": { "human": { "enum": [ "Kids", "Ad ...

Whenever a click event is triggered, the Vue method is executed twice

Why is the set method being executed twice? Check the console when you click the star. Removing @click="set(rating)" results in no action, indicating it is not called elsewhere. http://jsfiddle.net/q22tqoLu/ HTML <div id="star-app" v-cloak> ...

Unable to access variables beyond the function scope results in an undefined value

I'm currently working with an npm package that shortens URLs but I'm struggling because there isn't much documentation available. The package takes the "this.src" URL and shortens it, but when I try to use the "url" element in HTML, it retur ...

Dealing with the error "Type 'date[]' is not assignable to type '[date?, date?]' in a React hook

I'm attempting to assign a date range but encountering an error that states: Type 'Date[]' is not assignable to type '[Date?, Date?]'. Types of property 'length' are incompatible. Type 'number' is not assignab ...

Exploring the world of routing parameters in Express.js and AngularJS

Struggling to configure routes with parameters in an AngularJS application supported by a node.js server running on express. The setup involves Node routing all unspecified paths to a catch-all function: app.use(express.bodyParser()); app.use(app.router); ...

What sets MongoDB Shell Scripting apart from JavaScript?

I'm currently working on a homework assignment and I prefer not to share my code as it would give away the solution. However, I can provide some generic snippets. I must admit, I am a novice when it comes to javascript and Mongo, and I only learned ab ...

The "begin" parameter of the Angular limitTo filter appears to be ineffective in Angular version 1.3

Currently, I am attempting to implement a pagination feature on an array of users using Angularjs 1.3. ng-repeat="user in users | filter: searchText | orderBy: 'lastName' | limitTo:pageSize:startPosition track by user.lanId" I specifically want ...

Can we keep a portion of the input placeholder content?

The input box below accepts values in percentage form. To indicate this, I have set a placeholder that says Percentage (%). https://i.sstatic.net/LJ1ee.png My goal is to automatically add a % symbol to the value as soon as it is entered into the input fi ...

Expand the image to fill the entirety of the viewing area

Check out my development website. Whenever you click on an image, a photo slider (using photoswipe) pops up. Is there any way to have the image fill the entire viewport? I attempted using height: 100vh, width: auto, but it didn't work. https://i.ssta ...

Ways to obtain the ID of the following element using jQuery

Here is some HTML code, and I am trying to retrieve the ID of the next element from a clicked element with the class name "coba" or to get the ID of an element with the class name "coba2." <div class="dropdown"> <label>Category</label> ...

Ensuring HTML5 validation in Ionic

Currently, I am delving into the world of Ionic but encountering an issue with HTML5 validation not functioning as expected within the framework. Below is a snippet of my login form: <h3> Login </h3> <form> <input name="email ...

Python requests no longer retrieves HTML content

I am trying to extract a name from a public Linkedin URL using Python requests (2.7). Previously, the code was functioning correctly. import requests from bs4 import BeautifulSoup url = "https://www.linkedin.com/in/linustorvalds" html = requests.get(url ...

When programming with PHP and JavaScript, managing events' start dates and end dates

In my current project, I am developing a script that deals with events. An event is scheduled to start on 12/02/2016 at 11:20 and end on 01/04/2016 at 8:20. When the end date is reached, I need to trigger a specific action using JavaScript. if (t.getFullY ...

The use of a script redirect in PHP can result in a recursive

Hey there, I'm a new rank newbie here! So I have this code that's supposed to redirect users to the relevant page on both mobile and desktop. But it seems like it's causing a never-ending loop with the webpage constantly reloading. Should I ...

Creating a function in Angular to locate each object based on its ID

Hello there, I am currently working on creating a method called findChildByIdInData(data:any, childId:string). This method will take in a JSON main node with children that have unique IDs, and the goal is to find a specific object based on the ID provided ...

Exploring the Depths of the DOM: Enhancing User Experience with Jquery

I am facing an issue with my AJAX request in my page. After retrieving data from the database and trying to append it to a div, I am attempting to create an accordion interface without success. Below is a snippet of my source code after the AJAX call: ...

Accessing variables in subfunctions proves challenging for Node.js

Here is a function I've been working on to calculate the total price for a checkout process. However, when I console.log() the variable before it is returned, I get 0. But if I log the variable inside the findOne() function, I get the correct value. ...

Creating a Responsive Bootstrap Webpage

I attempted to replicate a sign-in page using Bootstrap from this link: Prior to this, I had already created a page without using Bootstrap code. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Mainpage.aspx.cs" Inherits="project.Mainpage" ...